str() and repr() - WBowam/wbowam.github.com GitHub Wiki

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'
⚠️ **GitHub.com Fallback** ⚠️