如何解決字串編碼亂碼的問題
import pandas as pd
df = pd.read_excel(r'C:\Users\mi\Desktop\fund.xlsx',\
header = 0,sep = '\t',encoding='UTF-8')
df.fillna({"證券簡稱":"好"})
但是運行的時候,出現了如下的亂碼
in:runfile('C:/Users/mi/.spyder-py3/temp.py', wdir='C:/Users/mi/.spyder-py3')
This command failed to be executed because an error occurred while trying to get the file code from Spyder's editor. The error was:
An exception has occurred, use %tb to see the full traceback.
UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 181: illegal multibyte sequence
這個問題該如何解決,謝謝各位大神
uj5u.com熱心網友回復:
猜一下:把'utf-8'換成'gbk'試試轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/235106.html
