开发者

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))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜