ringa_lee2017-04-18 09:32:21
You can try the f.read(size) function. If size is set to 1, it will read character by character, and then filter the data.
ringa_lee2017-04-18 09:32:21
This is easy to usepython
, but the result is the same, it’s because your posture is not right
For example, the content you filtered> twiiiiiii@2
, 我模拟一下, 假如待处理的文件(raw.dat
) is as follows
> t我w爱i北i京i天i安i门ii@2
Up code
with open("raw.dat", "rb") as fh:
line = fh.readline()
print(line)
print(line.decode('ascii', 'ignore'))
Output
b'> t\xce\xd2w\xb0\xaei\xb1\xb1i\xbe\xa9i\xcc\xeci\xb0\xb2i\xc3\xc5ii@2'
> twiiiiiii@2
So there’s no problem, it’s no different from what you use C