加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
CountMillionCharacters-2.0.py 589 Bytes
一键复制 编辑 原始数据 按行查看 历史
Jérôme Krell 提交于 2019-10-10 14:22 . Reformat Code by PyCharm-Community
"""Get the number of each character in any given text.
Inputs:
A txt file -- You will be asked for an input file. Simply input the name
of the txt file in which you have the desired text.
"""
import collections
import pprint
def main():
file_input = input('File Name: ')
try:
with open(file_input, 'r') as info:
count = collections.Counter(info.read().upper())
except FileNotFoundError:
print("Please enter a valid file name.")
main()
value = pprint.pformat(count)
print(value)
exit()
if __name__ == "__main__":
main()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化