首页 > 代码库 > python学习笔记

python学习笔记

1,从管道读取文件

import fileinputfor line in fileinput.input():    pass
import sysfor line in sys.stdin:    print line

 

2,逐行读取文件

for line in data:    ... do stuff ...
line = data.readline()while line:    # ... do stuff ...     line = data.readline()

 

python学习笔记