对给出的一段英文Python is a high-level general-purpose programming language Its design philosophy emphasizes code readability with the use of significant indentation Python is dynamically typed and garbage-co
代码如下:
text = "Python is a high-level, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation. Python is dynamically typed and garbage-collected."
while True:
word = input("请输入要查询的单词:")
if word == "quit":
break
count = text.count(word)
print("单词 {} 在文本中出现了 {} 次。".format(word, count))
运行结果如下:
请输入要查询的单词:Python
单词 Python 在文本中出现了 2 次。
请输入要查询的单词:is
单词 is 在文本中出现了 2 次。
请输入要查询的单词:quit
原文地址: https://www.cveoy.top/t/topic/YBt 著作权归作者所有。请勿转载和采集!