help in code
Steven D'Aprano
steve-REMOVE-THIS at cybersource.com.au
Tue Aug 24 03:15:08 EDT 2010
On Mon, 23 Aug 2010 22:40:04 -0700, pahi sharma wrote:
> I am new to python .I have a corpus which is written in Bengali and i
> want to read that file using python code.Can anyone help me in this
> matter.
In Python 3, I believe this should work:
f = open("filename", encoding="which-encoding-you-use")
text = f.read()
f.close()
In Python 2, you probably need to do this:
f = open("filename")
bytes = f.read()
text = bytes.decode('which-encoding-you-use')
f.close()
Hope this helps.
--
Steven
More information about the Python-list
mailing list