unicode text file

MRAB python at mrabarnett.plus.com
Sun Sep 27 10:34:26 EDT 2009


Junaid wrote:
> I want to do replacements in a utf-8 text file. example
> 
> f=open("test.txt","r") #this file is uft-8 encoded
> 
> raw = f.read()
> txt = raw.decode("utf-8")
> 
> txt.replace{'English', ur'ഇംഗ്ലീഷ്') #replacing raw unicode string,
> but not working
> 
txt = txt.replace{'English', ur'ഇംഗ്ലീഷ്')

> f.write(txt)
> f.close()
> f.flush()

The file will be flushed when it's closed, and flushing it after closing 
is meaningless.
> 
> 
> please, help me
> 
> thanks




More information about the Python-list mailing list