開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Python (プログラミング言語)
Learning Python (Mark Lutz (著)、Oreilly & Associates Inc)のPART Ⅱ.(Types and Operations)、Chapter 7.(String Fundamentals)、Test Your Knowledge: Quiz 1.を解いてみる。
その他参考書籍
Test Your Knowledge: Quiz 1.
No.
コード(BBEdit)
sample1.py
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
print("find('p')")
for x in ["python", "spam", "egg", [1, 2], [3, 4], [5, 6]]:
try:
print("{0}: {1}".format(x, x.find('p')))
except Exception as err:
print(err)
入出力結果(Terminal, IPython)
$ ./sample1.py
find('p')
python: 0
spam: 1
egg: -1
'list' object has no attribute 'find'
'list' object has no attribute 'find'
'list' object has no attribute 'find'
$
0 コメント:
コメントを投稿