문제

I got a .dat file, encoded in ANSI which contains NUL caracters (not only !).

I wan't to read it into a str object iot cut something in the whole str obtained.

But file.read() stops when the first NUL is reached.

I'm lost :)

My code :

file=open(source, mode='rt')
fulltext=file.read()
print(fulltext)

NUL is show with Notepad++ I'm on Windows XP, with PortablePython 3.2 The file is a special DAT file that can be edited with notepad as a text.

도움이 되었습니까?

해결책 2

As Evert has commented in my question, the problem was focused on the use of Pyscripter ! So, this question is closed :)

다른 팁

If you want to read bytes like 0, chances are your file is a binary file. Read in binary mode rb instead of text mode rt.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top