返回顶部

收藏

Reading a file: readlines and xreadlines

更多
file = open('test.txt', 'rb')
while 1:
    chunk = file.read(10)        # read byte chucks
    if not chunk: break
    print chunk,

for line in open('test.txt').readlines(): print line
for line in open('test.txt').xreadlines():print line
for line in open('test.txt'):             print line

标签:Python,File

收藏

0人收藏

支持

0

反对

0

发表评论