SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UX

在读取xlsx的时候,出现错误:

SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

解决办法有两种:

import pandas as pd
iris = pd.read_excel('C:\\Users\\lhh\\Desktop\\zlp\\iris.xlsx') #加转义符\
iris = pd.read_excel(r'C:\Users\lhh\Desktop\zlp\iris.xlsx')#加r在路劲之前;
print(iris)

你可能感兴趣的:(SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UX)