python案例,找出单词并输出行号
import re
wordname = input("Enter the new Shop Name: ")
with open('password.txt','r') as f:
lines = f.readlines()
for idx,line in enumerate(lines,1):
if re.search(wordname, line):
print(idx,line)
yield x from itertools import islice for x in islice(items,3,None): from itertools import dropwhile for line in dropwhile(lambda line:line.startswith(#),f) line.startswith('#') lines=(line for line in f if not line.startswith('#')) 去除#号开头
浙公网安备 33010602011771号