1、读取文本文档
红球.txt
2、运行代码
with open('红球.txt', "r", encoding="utf-8")as f: d = {} for j in f: ls = j.split() for num in ls: d[num] = d.get(num, 0) + 1 for i in d.items(): print(i[0],i[1])
3、效果显示
1、读取文本文档
红球.txt
2、运行代码
with open('红球.txt', "r", encoding="utf-8")as f: d = {} for j in f: ls = j.split() for num in ls: d[num] = d.get(num, 0) + 1 for i in d.items(): print(i[0],i[1])
3、效果显示