我发现,到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) –
以“/”开头的路径不是相对路径。 –