開発環境
- OS X Yosemite - Apple (OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Python 3.4 (プログラミング言語)
Introducing Python: Modern Computing in Simple Packages(Bill Lubanovic (著)、 O'Reilly Media)のChapter 3(Py Filling: Lists, Tuples, Dictionaries, and Sets)、Things to Do 3.15, 16, 17, 18.を解いてみる。
Things to Do 3.15, 16, 17, 18.
入出力結果(Terminal, IPython)
$ ipython Python 3.4.2 (default, Nov 1 2014, 16:32:22) Type "copyright", "credits" or "license" for more information. IPython 2.3.1 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. In [1]: life = dict(animals=dict(cats=['Henri', 'Grumpy', 'Lucy'], octopi={}, emus={}), plants={}, other={} ) In [2]: life Out[2]: {'animals': {'emus': {}, 'octopi': {}, 'cats': ['Henri', 'Grumpy', 'Lucy']}, 'other': {}, 'plants': {}} In [3]: life.keys() Out[3]: dict_keys(['animals', 'other', 'plants']) In [4]: life['animals'].keys() Out[4]: dict_keys(['emus', 'octopi', 'cats']) In [5]: life['animals']['cats'] Out[5]: ['Henri', 'Grumpy', 'Lucy'] In [6]: quit() $
0 コメント:
コメントを投稿