1、pandas读取文件时报错:
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
原因:
路径写为:C:\Users\Administrator.USER-20200802SR\Desktop\pythonlianxi
1、没有文件名及格式
2、斜杠错误
解决措施:
改1、在路径前面加r,即保持字符原始值的意思。
rC:\Users\Administrator.USER-20200802SR\Desktop\pythonlianxi'
2、替换为双反斜杠
pd.read_csv('C:\\Users\\Administrator.USER-20200802SR\\Desktop\\pythonlianxi\\firstFile.csv',encoding='utf-8')
3、替换为正斜杠
pd.read_csv('C:/Users/Administrator.USER-20200802SR/Desktop/pythonlianxi/firstFile.csv',encoding='utf-8')