Python连续输入关键词获取其在论文中的出现次数【简约版】
order = "yes"
while order == "yes" or order == "YES":
keyword = input("input the keyword\n")
j = 0
count = 0
with open('C:\\Users\\Administrator\\Desktop\\1.txt') as file:
for i in file:
for A in i:
if keyword[j] == A:
j = j + 1
else:
j = 0
if j == len(keyword):
count += 1
j = 0
file.close()
print(keyword + " " +str(count))
order = input("continue?yes^\n")