Created
February 11, 2010 01:07
-
-
Save banyan/301076 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ある値を文字列にしたい時は str() か repr() を使う | |
| # str() 関数は引数で与えた値を人間が読みやすい文字列に、 | |
| # repr()関数は引数で与えた値と等価な値を返すインタプリタ表現(リテラル表記)を文字列として返す | |
| list = ['a', 1, [1, 2, 3]] | |
| print list # => ['a', 1, [1, 2, 3]] | |
| print str(list) # => ['a', 1, [1, 2, 3]] | |
| print repr(list) # => ['a', 1, [1, 2, 3]] | |
| s = 'Hello! World!' | |
| print s # => Hello! World! | |
| print str(s) # => Hello! World! | |
| print repr(s) # => 'Hello! World!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment