【发布时间】:2016-12-10 10:36:59
【问题描述】:
我在 /Users/admin/Desktop 中有一个 script.py,我想在 /Users/admin//Desktop/folder/file.txt 中的文件上运行此脚本,而不更改当前目录。
问题:在命令行上最有效的方法是什么?我正在使用以下命令,结果与预期不符。
$ python script.py --script; /Users/admin/Desktop/file.txt
raise StopIteration('because of missing file (file.txt)')
StopIteration: because of missing file (file.txt)
【问题讨论】:
-
1) 分号会提前终止命令。 2) 你没有显示你的代码。
-
我有 2000 行长的代码!
-
您是否考虑将 file.txt 的路径作为参数传递给脚本?
-
@user3698773:只发布与问题相关的代码。见stackoverflow.com/help/mcve
标签: python command-line