Python 2.7 Python-os.path无法识别网络驱动器上的某些文件
我认为下面的代码将返回所有Python 2.7 Python-os.path无法识别网络驱动器上的某些文件,python-2.7,Python 2.7,我认为下面的代码将返回所有True。相反,它返回True和False的混合。os找不到的文件确实存在。还有其他人遇到过这个问题并找到了解决方案吗 >>> dirPath = r"W:\Some\Path" >>> os.path.isdir (dirPath) True >>> for di, sDi, files in os.walk (dirPath): for fil in files: filePath = o
True
。相反,它返回True
和False
的混合。os
找不到的文件确实存在。还有其他人遇到过这个问题并找到了解决方案吗
>>> dirPath = r"W:\Some\Path"
>>> os.path.isdir (dirPath)
True
>>> for di, sDi, files in os.walk (dirPath):
for fil in files:
filePath = os.path.join (di, fil)
print os.path.exists (filePath)
False
False
True
False
True
True
...
os.path.isfile
返回相同的结果。尝试:
dirPath = r"W:/Some/Path"
或
dirPath = r"W:\\Some\\Path"