我试图使用os.path.isfile来测试网络驱动器上是否存在文件,但即使文件存在,它也会返回false。任何想法,为什么这可能是我可以用来检查这个文件的任何其他方法?os.path.isfile()对网络驱动器上的文件返回false
我使用Python2.7和Windows10
这个,因为它应该返回true:
import os
if os.path.isfile("C:\test.txt"):
print "Is File"
else:
print "Is Not File"
这个返回false,即使该文件存在:
import os
if os.path.isfile("Q:\test.txt"):
print "Is File"
else:
print "Is Not File"
使用原始字符串:'os.path.isfile(r“Q:\ test.txt”)'? –
也返回false –
'os.path.exists()'返回什么? –