J'utilise Python 2.7.8 et j'ai un script qui n'analyse:Unicode ANSI ou UTF8 en python
def parse():
with open('myfile.txt') as f:
.
.
.
Print l
myfile.txt a un codage UNICODE. Comment puis-je ajouter un code à ce script afin qu'il lise le fichier myfile.txt en tant qu'ANSI par exemple?
Pourquoi ne pas utiliser 'unicode' en interne? Utilisez 'io.open()' et spécifiez le codage. –
Matériel de lecture: http://nedbatchelder.com/text/unipain.html, https://docs.python.org/2/howto/unicode.html et http://www.joelonsoftware.com/articles/Unicode .html –
[ANSI] (https://fr.wikipedia.org/wiki/American_National_Standards_Institute) - n'est pas un encodage. Voulez-vous dire [ASCII] (https://en.wikipedia.org/wiki/ASCII)? Dans ce cas, python s'ouvre en codage ASCII par défaut. – stalk