2016-06-21 92 views
0

我嘗試df.to_excel()並得到錯誤 UnicodeDecodeError: 'utf8' codec can't decode byte 0xd1 in position 175: invalid continuation byte。 接下來我嘗試df.to_excel(encoding='utf-8'),但錯誤並沒有消失/ 有什麼不對?嘗試寫入excel時出錯

+0

如果你只是張貼,似乎是造成問題的部分代碼會更容易些。 –

+1

你使用python 2嗎?你的'sys.getdefaultencoding()'說什麼?請注意這是**解碼**錯誤。可能在某些時候,某個東西在包含其他編碼的字節字符串上調用'.encode('utf8')',因爲python 2然後隱式地首先嚐試'.decode()'。請包括你正在做的最簡單的例子以及你得到的完整回溯。 –

+0

@IljaEverilä,它返回'ascii' – ldevyataykina

回答

0

你可以嘗試

import sys 
reload(sys) 
sys.setdefaultencoding("latin-1") 

做不到這一點,嘗試sys.setdefaultencoding('utf-8')

相關問題