Python

[Python] operator.itemgetter

Word Counter Sorted by Times(Chinese Version):

import operator
in_file = open("input.txt")
raw_article = in_file.read()
table={}
for word in raw_article:
 if word in table:
   table[word] = table[word]+1
 else:
   table[word] = 1
sorted_table = sorted(table.items(),key=operator.itemgetter(1),reverse=True)
for pair in sorted_table:
 print(pair[0],":",pair[1])

[Python] Anaconda

  • numpy and matplotlib
import numpy as np
import matplotlib.pyplot as pt
x = np.arange(0,360)
y = np.sin(x*np.pi/180)
pt.plot(x,y)
pt.xlim(0,360)
pt.ylim(-2,2)
pt.title("SINE")
pt.show()
%e6%9c%aa%e5%91%bd%e5%90%8d

[Python] requests

import requests
www = requests.get("http://www.google.com")
print(www.text)