じゃあ、おうちで学べる

本能を呼び覚ますこのコードに、君は抗えるか

Python で調べるけど 出現頻度が高い文字は何か?

一番使われている文字を探す

どの文字の出現頻度が高いのか気になる場合がある. 日本語でPythonであれば一瞬で出来る.

$cat count.py
# -*- coding: utf-8 -*-

f = open('sv.txt')
data = f.read()

# counting
words = {}
for word in list(data):
    words[word] = words.get(word, 0) + 1

# sort by count
d = [(v,k) for k,v in words.items()]
d.sort()
d.reverse()
for count, word in d[:60]:
    print (count, word)

github.com

おまけ

Rust