Skip to content

Instantly share code, notes, and snippets.

@lyo
Created November 15, 2020 06:33
Show Gist options
  • Save lyo/a537a7a9115596730548d59bc3c5685c to your computer and use it in GitHub Desktop.
Save lyo/a537a7a9115596730548d59bc3c5685c to your computer and use it in GitHub Desktop.
アルファベット出現頻度確認
import collections, sys
from string import ascii_lowercase
def filecharcount(openfile):
return sorted(collections.Counter(char for line in
openfile for char in line.lower() ).items())
f = open(sys.argv[1])
for letter, repetitions in filecharcount(f):
print(letter, repetitions)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment