我有一個python腳本,它是此目錄下:的Python:子與不同的工作目錄
work/project/test/a.py
裏面a.py
,我用subprocess.POPEN
從另一個目錄中啓動進程,
work/to_launch/file1.pl, file2.py, file3.py, ...
的Python代碼:
subprocess.POPEN("usr/bin/perl ../to_launch/file1.pl")
and under work/project /,I type following荷蘭國際集團
[[email protected] project]python test/a.py,
錯誤「file2.py,‘沒有這樣的文件或目錄’」
如何新增work/to_launch/
,讓這些相關文件可以找到?
你可以嘗試在全光照POPEN CWD說法:http://stackoverflow.com/questions/1685157/python-popen-working-directory-argument – Ayrat 2012-03-29 13:16:42
在Python使用'進口OS '然後'os.chdir('/ tmp/yourdirectory')'這會爲你的python腳本設置當前目錄。 – 2014-01-04 22:30:32