所以我应该按照这种格式来查找文本文件的出现次数。
但我的代码可能是完全错误的。
text = open('text3.txt','r')
d = dict()
fname = input('Enter the file name:')
l = input('Enter letter to be searched:')
k = 0
with open(fname, 'r') as f:
for line in f:
words = line.split()
for i in words:
for letter in i:
if(letter == 1):
k = k+1
print('Occurences of the letter:')
print(k)
有人可以帮我吗?
MYYA
相关分类