解决python中路径中包含中文无法找到文件的问题


a="C:\Users\Dell\Desktop\ATOU\公共测试用例" (带中文的路径)

a=a.decode("utf-8").encode("gbk") (进行转码)

import sys 

sys.path.append(a)  (指定路径成功)

合并起来一条:

import sys
sys.path.append("C:\Users\Dell\Desktop\ATOU\公共测试用例".decode("utf-8").encode("gbk"))