Last active
June 23, 2016 02:36
-
-
Save tacaswell/06f8c423f9df0d01f9f4886b96665249 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Quick example on how to read utf-8 files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Olá Tom! Espero que vocês não estão demasiado quentes em Nova York | |
... Eu tenho uma pergunta python , o que pode ser uma pergunta muito | |
estúpida , tão à vontade para me dizer se é : Python pode lidar com | |
sinais diacríticos no texto, certo? Estou ajudando um processo membro | |
do corpo docente e analisar um romance escrito em Português, de modo | |
que o texto tem um monte de acentos ( A, C, E , etc.) e estou tendo | |
problemas para abrir esse texto em IDLE . É um arquivo de texto | |
simples codificados em UTF- 8, mas se eu tentar abri-lo no IDLE para | |
andar , eu recebo um " codec ascii não pode decodificar " tipo de erro | |
que indica a posição do personagem que não reconhece . Eu sinto que | |
deve estar faltando algo super óbvio, mas eu não tenho sido capaz de | |
encontrar uma solução ( eu não posso nem acessar a documentação em | |
língua espanhola , por algum motivo ) . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
with open('inp.txt') as fin: | |
for ln in fin: | |
print(ln.decode('utf-8').strip()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open('inp.txt', encoding='utf-8') as fin: | |
for ln in fin: | |
print(ln.strip()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment