Python中的repr()函数

Python 有办法将任意值转为字符串:将它传入repr() 或str() 函数。

    函数str() 用于将值转化为适于人阅读的形式,而repr() 转化为供解释器读取的形式。

  在python的官方API中这样解释repr()函数:

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA/UAAACfCAIAAAA3Xm4PAAAgAElEQVR4nO2dQZrkNq5uY1H2Zt7Eg96Gt9Czt5WevhXc6Z30ZvQGZaeVIgH8ACGFQnnOoL4IkQR+gCCFSperXhsAAAAAADyF17sFAAAAAABAG/T3AAAAAADPgf4eAAAAAOA50N8DAAAAADwH+nsAAAAAgOdAfw8AAAAA8Bzo7wEAAAAAngP9PQAAAADAc3hCf/963TGKe6oCAAAAgGfz8T3ondvoO2sDAAAAgEfy2Q3o/Rvo+ysEAAAAgCfx2d3n/bvn+ysEAAAAgCfxwd3nSuvsr21pyr+M0OIDAAAAwGV8cOtZ7pvD5n69I99boL8HAAAAgMv44NbzpP6+Bfp7AAAAAHgLhdbzP/96/c2//rP999+/fX397d//3c3bj3wb/NvAv/6zMzWd4bpQfgz/xWHoMGFcO7Ujujg8ob8HAAAAgMsot57//fdvr9dvv/32q+f+qyH/13/2o7tu/K/vx/F/Hv394GtG6MLrm6cN/dfnsR13Jh8WZlf5OgEAAAAAelnr71/Hn9n/xa9efN+r//Xo79nHfn/6yHVh983T5/5P06fdufNz/fA/HSg6AQAAAADaWezv56334U/m7HD6+8PvAAIXW6a/9/+0jPWD+WkAvuvpKP09AAAAAFzGKf398EdpjNUn9Pfn/fDed+GM0t8DAAAAwGWc0t+Prfpfz8w/j7/NflNwr/6+9sP7cD4AAAAAQCPn9PfD/y776/s/vfvXn+A5/O+13+wF/f2m/WEb/eu2Hf9wztRRaNNXCAAAAABwHmt/P+bfOP+T7XzO7q/G+Yd/2n/VhfXz+C/GydboaM2f6Q/5CgEAAAAATuJN3eev/t75ybxMYwPd3ovT3AMAAADAxbyjAf320/mGJn+9jZ7+JH7dZq9BAAAAAIAQelAAAAAAgOdAfw8AAAAA8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VORK5CYII=

repr()函数得到的字符串通常可以用来重新获得该对象,repr()的输入对python比较友好。通常情况下obj==eval(repr(obj))这个等式是成立的。

>>> obj='I love Python'
>>> obj==eval(repr(obj))
True

而str()函数这没有这个功能

>>> obj==eval(str(obj))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 1
    I love Python
         ^

repr()函数:

>>>repr([0,1,2,3])
'[0,1,2,3]'
>>> repr('Hello')
"'Hello'"

>>> str(1.0/7.0)
'0.142857142857'
>>> repr(1.0/7.0)
'0.14285714285714285'

 

posted on 2015-12-14 20:04  波比12  阅读(51456)  评论(0编辑  收藏  举报

导航