the.bay.news

Is there a way to change the linesep in open()?

Discussions on Python.org
Is there a way to change the linesep in open()?
The infile was encoded in UTF_16_LE and each line is end with “0x0d 0x00 0x0a 0x00”. When running the following code, Python read each line with end of “0x0d 0x00 0x0a” and causing the following error. with open(infile, "rb") as f: for line in f: line_text = line.decode('utf_16_le') Traceback (most recent call last): File “d:\Works\Python\2utf8.py”, line 25, in line_text = line.decode(‘utf_16_le’) ^^^^^^^^^^^^^^^^^^^^^^ UnicodeDecodeError: ‘utf-16-le’ codec can’t decode byte 0...

The infile was encoded in UTF_16_LE and each line is end with “0x0d 0x00 0x0a 0x00”. When running the following code, Python read each line with end of “0x0d 0x00 0x0a” and…

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.