Created
January 28, 2010 03:37
-
-
Save amundo/288417 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import codecs | |
sys.stdout = codecs.getwriter('utf-8')(sys.stdout) | |
content = open(sys.argv[1],'rU').read().decode('utf-8') | |
letters = list(content) | |
letterfq = {} | |
for letter in letters: | |
if letter in letterfq: letterfq[letter] += 1 | |
else: letterfq[letter] = 1 | |
byfq = sorted([(v,k) for k,v in letterfq.items()]) | |
for fq, letter in byfq: | |
print letter, fq | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment