我發現,到proceess按文件名指定的文件,我需要做的本地相對文件名在Python中意味着什麼?
import os
dir = os.path.dirname(__file__)
filename = os.path.join(dir, '/relative/path/to/file/you/want')
或
import os
dir = os.getcwd()
filename = os.path.join(dir, '/relative/path/to/file/you/want')
但如果我這樣做
filename = 'myfile.txt'
然後在那裏將尋找這個文件?
http://stackoverflow.com/questions/918154/relative-paths-in-python可能會有所幫助,看看。 – whrrgarbl
[os.getcwd()vs os.path.abspath(os.path.dirname(\ _ \ _ file \ _ \ _))]的可能重複(http://stackoverflow.com/questions/11274040/os-getcwd -vs-os-path-abspathos-path-dirname-file) –
以「/」開頭的路徑不是相對路徑。 –