Tugqi Biz
  • Home
  • Categories
  • Tags
  • Archives

str()与repr()的区别

一¶
>>> 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'

  • « Mysql语句入门(1)
  • python exec和eval语句 »

Published

Jul 1, 2014

Category

It

Tags

  • Python 15
  • Powered by Pelican. Theme: Elegant by Talha Mansoor