[英]Encoding issue during reading excel file in Python
我使用 pandas 庫中的read_excel
來讀取 excel 內容並將其轉換為 JSON。 我正在努力解決編碼問題。 非英文字符編碼為"u652f\援\資\訊"
。 我該如何解決這個問題? 我試過
wb = xlrd.open_workbook(excel_filePath, encoding_override='ISO-8859-1')
new_data = pd.read_excel(wb)
還
with open(excel_filePath, mode="r", encoding="utf-8") as file:
new_data = pd.read_excel(excel_filePath)
我用類似的編碼嘗試了這段代碼: utf-8, utf-16, utf-16, latin1...
試試這個
with open(json_filePath, 'w', encoding='utf-8') as f:
json.dump(new_json, f, ensure_ascii=False)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.