!!!Python3 {{amazon 479738946X}} *[Python3ドキュメント|http://docs.python.jp/3/] **[言語|http://docs.python.jp/3/reference/index.html] **[ライブラリ|http://docs.python.jp/3/library/index.html] **[モジュール|http://docs.python.jp/3/py-modindex.html] *[Python2からPython3.0での変更点|http://qiita.com/CS_Toku/items/353fd4b0fd9ed17dc152] !!!言語 !!内包表記 !基本 *http://docs.python.jp/3/tutorial/datastructures.html?highlight=%E5%86%85%E5%8C%85 *シーケンスや iterable (イテレート可能オブジェクト) のそれぞれの要素に対してある操作を行った結果を要素にしたリストを作ったり、ある条件を満たす要素だけからなる部分シーケンスを作成する >>> [x**2 for x in range(10)] [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] !二重ループと条件 *式、 for 句、そして0個以上の for か if 句で構成 >>> [(x, y) for x in [1,2,3] for y in [3,1,4] if x != y] [(1, 3), (1, 4), (2, 3), (2, 1), (2, 4), (3, 1), (3, 4)] *以下と等価 >>> combs = [] >>> for x in [1,2,3]: ... for y in [3,1,4]: ... if x != y: ... combs.append((x, y)) ... >>> combs !ネスト *ネストしたリストを展開 >>> [col for row in [[1,3,5],[2,4,6]] for col in row] [1, 3, 5, 2, 4, 6] !!!ライブラリ !!書式 !辞書を展開する >>> d = {'a':'aaa','b':'bbb'} >>> "a.is {0[a]}, b is {0[b]}".format(d) >>> 'a.is aaa, b is bbb'  !!!Web !!GET,POSTリクエスト from urllib.request import urlopen from urllib.parse import urlencode post_data = { 'searchway':'date', 'year':'2016', 'month':'12', 'day':'31', 'kaigou':'', 'howmany':'100' } # HTTP リクエストは、data パラメーターが指定された場合 POST に、指定されない場合に GET になります。 html = urlopen('http://www.takarakujinet.co.jp/ajax/numbers3/pastResultPage.do', urlencode(post_data).encode('utf-8')) for l in html.readlines(): print(l)