getchar - diffrent of Python readline() and C getc()
巴扎黑
巴扎黑 2017-04-18 09:30:21
0
2
470
巴扎黑
巴扎黑

reply all(2)
左手右手慢动作

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.

左手右手慢动作

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!