Is reverse reading possible?
antonyliu2002 at yahoo.com
Sun Mar 14 21:53:52 CET 2004
Hmm, it looks cool. I actually don't know what
encoding is used for those Chinese documents. How can
Can I do something like
to get its encoding?
--- Jeff Epler <jepler at unpythonic.net> wrote:
> 4M files are not that big these days.
> def reversed_file(name, encoding):
> contents = codecs.open(name, "r",
> contents = list(contents)
> return "".join(contents)
> >>> codecs.open("utf-example.txt", "r",
> u'60: CJK UNIFIED IDEOGRAPHS (0x4E00 - 0x9FFF) |
> >>> reversed_file("utf-example.txt", "utf-8")
> u'\n\u6f25\u5f25\u4e25 | )FFF9x0 - 00E4x0(
> SHPARGOEDI DEIFINU KJC :06'
> This assumes that you know the encoding for each
> file in advance, and
> that Python has a codec for it.
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
More information about the Python-list