【发布时间】:2015-10-20 11:42:44
【问题描述】:
import os
myDir = "C:\\temp\\a"
for root, dirs, files in os.walk(myDir):
for file in files:
# fname = os.path.join(root, file) # this works fine, yeah!
fname = os.path.join(myDir, file)
print ("%r" % (fname))
src = os.path.isfile(fname)
if src == False:
print ("%r :Fail" % (fname))
f = open(fname,"r")
f.close()
我希望两个版本的 fname 相同,但我发现上面的代码不起作用。我只是想知道为什么,仅此而已。
【问题讨论】:
标签: python-2.7 path filenames