2014年7月17日木曜日

開発環境

Practical Programming: An Introduction to Computer Science Using Python 3 (Pragmatic Programmers) (Paul Gries (著)、Jennifer Campbell (著)、Jason Montojo (著)、Lynn Beighley (編集)、Pragmatic Bookshelf)のChapter 4(Working with Text)、4.7(Exercises) 3.を解いてみる。

4.7(Exercises) 3.

入出力結果(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
   ...: B
   ...: C'''

In [2]: s1 = "A\nB\nC"

In [3]: s2 = 'A\nB\nC'

In [4]: s == s1
Out[4]: True

In [5]: s == s2
Out[5]: True

In [6]: s
Out[6]: 'A\nB\nC'

In [7]: s1
Out[7]: 'A\nB\nC'

In [8]: s2
Out[8]: 'A\nB\nC'

In [9]: print(s, s1, s2, sep='\n')
A
B
C
A
B
C
A
B
C

In [10]: print(s, s1, s2, sep='\n\n')
A
B
C

A
B
C

A
B
C

In [11]: quit()
$

0 コメント:

コメントを投稿