UnicodeDecodeError, invalid continuation byte

前端 未结 10 2128
忘掉有多难
忘掉有多难 2020-11-22 08:25

Why is the below item failing? Why does it succeed with "latin-1" codec?

o = "a test of \\xe9 char" #I want this to remain a string as thi         


        
10条回答
  •  滥情空心
    2020-11-22 09:03

    I had the same error when I tried to open a CSV file by pandas.read_csv method.

    The solution was change the encoding to latin-1:

    pd.read_csv('ml-100k/u.item', sep='|', names=m_cols , encoding='latin-1')
    

提交回复
热议问题