jupyter (python3) 读取文件遇到的问题

1、出现错误


      train_df = pd.read_csv('C:\Users\lenovo\Desktop\train.csv',encoding='utf-8')
    
     报错: File "<ipython-input-45-27822e1fee69>", line 1
    train_df = pd.read_csv('C:\Users\lenovo\Desktop\train.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:\Users\lenovo\Desktop\train.csv',encoding='utf-8')

 

   
阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页