2017-02-28 1 views
1

일련의 유니 코드 문자 (ransomware 이름)가 포함 된 스프레드 시트를 처리하고 있습니다. 순간판다로 유니 코드 문자를 처리하고 화면에 인쇄하는 방법은 무엇입니까?

나는 다음과 같은 한 :

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"

처리 할 수있는 방법이 있습니까, 아니면 파소 ver이 내 스프레드 시트 용 팬더를 사용하고 있습니까?

+0

터미널이 유니 코드를 지원합니까? –

+0

@ juanpa.arrivillaga 나는 그것을 고려하지 않았다. 지금 bash에서 테스트하고 업데이트 할 것입니다 ... – Codingo

+0

전에 유니 코드를 지원하지 않는 터미널에'print '하려고하면'UnicodeEncodeError'를 보았습니다 ... –

답변

2

일부 옵션 : 대신 CP850에서 출력 (시스템에 콘솔의 기본 인코딩)을 인코딩하는 시도의 콘솔에 쓸 윈도우 유니 코드 API를 사용하여 파이썬 3.6

  1. 스위치.
  2. 콘솔 인코딩을 chcp 65001 (UTF-8)으로 변경하십시오.
  3. 스크립트를 실행하기 전에 환경 변수 pythonioencoding=cp850:replace을 설정하십시오. 그러면 오류 처리기가 strict에서 replace으로 변경됩니다. cp850에서 지원하지 않는 문자에 대해 물음표가 표시됩니다.
+0

파이썬 3.4 ... 너무 닫습니다! 나는 업데이트하고 당길 것이다. 조언 해주셔서 감사합니다! – Codingo

관련 문제