unicode text file

Vlastimil Brom vlastimil.brom at gmail.com
Sun Sep 27 08:17:37 EDT 2009


2009/9/27 Junaid <junu.pv at gmail.com>:
> 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
>
> f.write(txt)
> f.close()
> f.flush()
>
>
> please, help me
>
> thanks
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Does
txt.replace('English', ur'ഇംഗ്ലീഷ്')
instead of
txt.replace{'English', ur'ഇംഗ്ലീഷ്')

fix the problem?

hth
  vbr



More information about the Python-list mailing list