開発環境
- OS X Lion - Apple(OS)
- TextWrangler(Text Editor) (BBEditの無料機能制限版、light版)
- Script言語: Python
『初めてのPython 第3版』(Mark Lutz 著、夏目 大 訳、オライリー・ジャパン、2009年、ISBN978-4-87311-393-7) のII部(ビルトインオブジェクト)のまとめ演習5(ディクショナリのキー)を解いてみる。
5.
ディクショナリのキーには不変性をもつオブジェクト(整数、数値、タプル)を使うことができるから。
入出力結果(Terminal)
$ python Python 3.2.3 (default, Apr 18 2012, 20:17:30) [GCC 4.2.1 Compatible Apple Clang 3.0 (tags/Apple/clang-211.12)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> D={} >>> D[1]='a' >>> D[2]='b' >>> D {1: 'a', 2: 'b'} >>> D[(1,2,3)]='c' >>> D {1: 'a', 2: 'b', (1, 2, 3): 'c'} >>> quit() $
0 コメント:
コメントを投稿