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

1、出现错误


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

 

   

你可能感兴趣的:(jupyter (python3) 读取文件遇到的问题)