我正在處理包含一系列unicode字符(勒索軟件名稱)的電子表格。如何處理大熊貓的Unicode字符和打印到屏幕?
此刻,我有以下幾點:
import urllib.request
import pandas as pd
SOURCESHEET = 'https://docs.google.com/spreadsheets/d/1TWS238xacAto-fLKh1n5uTsdijWdCEsGIM0Y0Hvmc5g/pub?output=xlsx'
WORKBOOK = 'RansomwareOverview.xlsx'
# download and save ransomware overview file locally
try:
urllib.request.urlretrieve(SOURCESHEET, WORKBOOK)
except IOError:
print('An error occured trying to write an updated spreadsheet. Do you already have it open?')
except urllib.error.URLError:
print('An error occured trying to download the file. Please check the source and try again')
sheet = pd.read_excel(open(WORKBOOK,'rb'), sheetname='Ransomware')
print(sheet)
當我嘗試板材print
內容我收到以下內容:
Traceback (most recent call last): File "GoogleSpreadsheetToJson.py", line 27, in print(sheet) File "C:\Python34\lib\encodings\cp850.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_map)[0] UnicodeEncodeError: 'charmap' codec can't encode characters in position 10917-10922: character maps to
我相信這是因爲片狀我使用具有以下屬性:
"ПРОЧТИ_МЕНЯ.txt READ_ME.txt"
有沒有一種方法可以處理或passo同時仍然使用熊貓作爲我的電子表格?
您的終端是否支持unicode? –
@ juanpa.arrivillaga我沒有考慮過。我將在bash上測試它並更新... – Codingo
當我嘗試將'print'打印到不支持unicode的終端之前,我已經看到'UnicodeEncodeError' ... –