2024-05-29 11:02:50 发布
网友
我是一个非常困惑的初学者,我想知道我应该做些什么来使这项工作。我的IDE没有给我一个错误,只是没有输出
我想计算一个单词在一本书的文本文件中被找到的次数,在这种情况下,“the”就是这个单词:
with open('heidi.txt', 'r') as file: content = file.read() content.count('the')
count()不打印任何内容。给一个变量,像这样-
count()
with open('heidi.txt', 'r') as file: content = file.read() a = content.count('the') print(a)
我学习的示例是在控制台中运行它,因此我不知道需要使用print()。谢谢你@hilberts\u酗酒问题
with open('heidi.txt', 'r') as file: content = file.read() print(content.count('the '))
count()
不打印任何内容。给一个变量,像这样-我学习的示例是在控制台中运行它,因此我不知道需要使用print()。谢谢你@hilberts\u酗酒问题
相关问题 更多 >
编程相关推荐