Skip to content
tulpar edited this page Apr 13, 2015 · 1 revision

Date: 2014-07-1
Title: str()与repr()的区别 Tags: Python Category: It

>>> word="hello\t world!\nhello motto!"
>>> str(word)
'hello\t world!\nhello motto!'
>>> repr(word)
"'hello\\t world!\\nhello motto!'"
>>> print str(word)
hello	 world!
hello motto!
>>> print repr(word)
'hello\t world!\nhello motto!'
>>>
>>> str(0.1)
'0.1'
>>> repr(0.1)
'0.10000000000000001'

Clone this wiki locally