#案例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'):标签:遍历,循环,文本文件,fileinput,print,line,循环体 From: https://www.cnblogs.com/yl6688/p/17110250.html
print(type(line))
print(line)#循环体