Reading corrupted file in python
I've got a file, that looks like this alt text http://img40.imageshack.us/img40/4581/crapq.png No开发者_如何学Pythonw there are 5 lines shown. However running this script
with open('hello.txt', 'r') as hello:
for line in hello:
print line,
gives
num 1
ctl00$header1$Login1$txtUserName=ыют;CBШ▌
and that's all. How can I read entire file? TIA
entire_file = open('hello.txt', 'rb').read()
print 'number of \\n: %d, number of bytes %d' % (
entire_file.count('\n'), len(entire_file))
精彩评论