python设计
编写一个程序,统计jianjie.txt文件中各字词出现的次数,用字典存储,并将统计结果写到1.txt,jianjie.txt全是中文大佬们这个咋写呀 把jianjie.txt发出来? f = open('jianjie.txt', encoding = 'utf-8')
words = dict()
for word in f.read():
if word in '\n ':
continue
words = words.get(word, 0) + 1
f.close()
f = open('1.txt', 'w')
for i in words:
f.write(f'{i}出现了{words}次\n')
f.close()
tommyyu 发表于 2022-12-18 10:37
好的,感谢感谢
lxping 发表于 2022-12-18 10:26
把jianjie.txt发出来?
解决了,感谢感谢
学习下,有收获
页:
[1]