Python的os.path.exists判断中文路径时,给以gbk(或gb2312)编码,才能找到,否则为False.
例如:
#-*-coding:utf-8-*-
a=r"d:\测试.txt"
b=r"d:\abc123.txt"
c=a.encode('gbk')
d=e.encode('gbk')
import os
print(os.path.exists(a))
>>>False
print(os.path.existss(b))
>>>True
print(os.path.exists(c))
>>>True
print(os.path.exists(d))
>>>True