Sto usando Python 2.5. Che cosa sta succedendo qui? Che cosa ho frainteso? Come posso ripararlo?Problema UTF-8 in python durante la lettura di caratteri
in.txt:
Stäckövérfløw
code.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
print """Content-Type: text/plain; charset="UTF-8"\n"""
f = open('in.txt','r')
for line in f:
print line
for i in line:
print i,
f.close()
uscita:
Stäckövérfløw
S t � � c k � � v � � r f l � � w
grazie, perfetto! – jacob
Il parametro 'r' in 'codecs.open' in realtà significa 'rb' (nessuna conversione '\ n') – jfs