练习,循环读取txt文档中a的所在行号

with open('a.txt','a+') as f:
f.seek(0)
fr = f.readlines()
for i in fr:
if i.count('a'):
print(fr.index(i)+1)

posted on 2020-04-01 11:18  奥喵  阅读(212)  评论(0编辑  收藏  举报

导航