how to control file output encoding?
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Wed Sep 20 02:46:35 EDT 2006
In <mailman.307.1158727737.10491.python-list at python.org>, MaTianyi wrote:
> the encoding of file that is output by the file.write() function is
> always None.
> and the encoding attribute of the File Object is readonly.
>
> f = open('abc.txt','w')
> print f.encoding
>>>> None
>
> how can I change the file output encoding?
Use the `open()` function in the `codecs` module:
import codecs
f = codecs.open('abc.txt', 'w', 'utf-8')
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list