開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Python (プログラミング言語)
Learning Python (Mark Lutz (著)、Oreilly & Associates Inc)のPART II.(Types and Operations)、Test Your Knowledge: Part II Exercises、3.(Indexing,slicing,and del)を解いてみる。
その他参考書籍
3.(Indexing,slicing,and del)
入出力結果(Terminal)
$ python3 Python 3.3.4 (default, Feb 10 2014, 22:06:52) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> l=[1,2,3,4] >>> l[2] = [] >>> l # [1, 2, [], 4] [1, 2, [], 4] >>> l[2:3] = [] >>> l # [1,2,4] [1, 2, 4] >>> l[2:3] = [3] >>> l # [1,2,3,4] [1, 2, 3] >>> l=[1,2,4] >>> l[2:3] = [3,4] >>> l # [1,2,3,4] [1, 2, 3, 4] >>> del l[0] >>> l # [2,3,4] [2, 3, 4] >>> del l[1:] >>> l # [2] [2] >>> l[1:2] = 1 # エラー Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: can only assign an iterable >>> quit() $
0 コメント:
コメントを投稿