本篇文章小编给大家分享一下解决jupyter读取文件遇到的问题代码示例,文章代码介绍的很详细,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。
1、出现错误
train_df = pd.read_csv( 'C:UserslenovoDesktoptrain.csv',encoding='utf-8')
报错:
File "
train_df = pd.read_csv('C:UserslenovoDesktoptrain.csv',encoding='utf-8') ^
SyntaxError : (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated UXXXXXXXX escape
2、 解决方案
文件名前面加r
train_df = pd.read_csv( r'C:UserslenovoDesktoptrain.csv',encoding='utf-8')