python3读取指定字段,并批量读入

版权声明:原创文章转载请声明出处 https://blog.csdn.net/qq_40374604/article/details/83445898
#shell指令,批量传入
cat titleTest*.txt | python3 readFileTest2.py
#读取传入文件指定字段
#auto=wangshiyu
#File=readFileTest2.py

import sys

for line in sys.stdin:
	start=line.find('<title')
	end = line.find(('>'),len('>')+start)
	print( line[start+7:end])

猜你喜欢

转载自blog.csdn.net/qq_40374604/article/details/83445898