Python stops reading file using read

后端 未结 2 329
感情败类
感情败类 2021-01-20 12:52

I\'m trying to read a binary file and am getting confusing results.

f = open(\'foo.dat\',\'r\')

data = f.read()

print len(data), f.tell()

2条回答
  •  离开以前
    2021-01-20 13:23

    data is a str object, thus len(data) tells you about the length of this string, not the file length in bytes.

提交回复
热议问题