文件明明存在,但是用os.path.exists() 返回False,通过试验发现,路径或者文件名中还有中文就会返回fasle,所以文件夹的名称或者文件名最好不要含有中文
试验代码如下,这四个文件都是存在的
print "E:/ruanjian/2222.txt存在吗?%s" % os.path.exists("E:/ruanjian/2222.txt")
print "E:/学习资料/2222.txt存在吗?%s" % os.path.exists("E:/学习资料/2222.txt")
print "E:/ruanjian/python模块的作用.doc存在吗?%s" % os.path.exists("E:/ruanjian/python模块的作用.doc")
print "E:/学习资料/python模块的作用.doc存在吗?%s" % os.path.exists("E:/学习资料/python模块的作用.doc")
试验结果
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)