#案例1,多文件行遍历循环
import fileinput
for line in fileinput.input(files=('g:\main.py','g:\yibao.txt')):
print(line)
print('hello,world')#循环体
fileinput.close()
#案例2,单文件行遍历循环
import fileinput
for line in fileinput.input(files='g:\yibao.txt'):
print(line)
print('hello,world')#循环体
fileinput.close()
#案例3,文本文件行遍历(经典、简单)
for line in open('g:\yibao.txt'):
print(type(line))
print(line)#循环体