gpt4 book ai didi

lua - 如何在 Torch REPL 中更改工作目录

转载 作者:行者123 更新时间:2023-12-04 07:26:07 27 4
gpt4 key购买 nike

标题说明了一切,如何更改 Torch REPL 中的工作目录?我尝试使用对 os.execute('cd some_dir') 的调用,但这不起作用,如此处所示。
th> pwd()--prints:/home/user/Codeth> os.execute('cd ..')--prints: true 退出 0th> pwd()-- 打印:/home/user/Code

其中 pwd() 是一个调用 os.execute('pwd') 的便捷函数。

最佳答案

安装 lfs 包(可能已经安装,如果没有“luarocks install luafilesystem”)

然后,

lfs=require 'lfs'
lfs.chdir(newdir)

此外,在 Torch REPL 中,您可以执行带有 $ 前缀的 shell 命令
例子:
th> $ls

关于lua - 如何在 Torch REPL 中更改工作目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29955356/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com