2014年8月9日土曜日

開発環境

Learning Python (Mark Lutz (著)、Oreilly & Associates Inc)のPART Ⅱ.(Types and Operations)、Chapter 7.(String Fundamentals)、Test Your Knowledge: Quiz 6.を解いてみる。

その他参考書籍

Test Your Knowledge: Quiz 6.

入出力結果(Terminal, IPython)

$ ipython
Python 3.4.1 (default, May 21 2014, 01:39:38) 
Type "copyright", "credits" or "license" for more information.

IPython 2.1.0 -- 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]: s = 'a\nb\x1f\000d'

In [2]: len(s) # 6
Out[2]: 6

In [3]: for ch in s: # a, \n, b, \x1f, \000, d
   ...:     print(ch)
   ...: 
a


b
 
 
d

In [4]: for ch in s: # a, \n, b, \x1f, \000, d
   ...:     print(repr(ch))
   ...: 
'a'
'\n'
'b'
'\x1f'
'\x00'
'd'

In [5]: quit()
$

0 コメント:

コメントを投稿