saving cyrillic text files

Boudewijn Rempt boud at
Fri Aug 23 09:56:52 CEST 2002

DR wrote:

> file=open("rustext.txt", "w")
> file.write("??????")
> file.close
> When I open the file with a text editor I get garbled text. I use
> russian win98 so I don't see why this shouldn't work.

Probably because Python hard-codedly assumes you want ASCII and
nothing but ASCII. Try something like:

import codecs

f ="rustext.txt","w","iso8859_5")

Boudewijn Rempt |

More information about the Python-list mailing list