python直接读取中文路径的文件时失败,可做如下处理:
python 2.7 file_location = "D:/花椒/土拨鼠/2022/a.xlsx" uipath = unicode(file_location, "utf8") python 3.10 file_location = "D:/花椒/土拨鼠/2022/a.xlsx" uipath = str(file_location)
然后用"uipath"经过编码后的路径去open()即可:
fin = open(uipath)