2019-01-04
阅读量:
660
python的repr函数
str()和repr()都用于获取对象的字符串表示。
- str()的示例:
s = 'Hello, Geeks.'
print str(s)
print str(2.0/11.0)
2. repr()的示例:
s = 'Hello, Geeks.'
print repr(s)
print repr(2.0/11.0)
从上面的输出,我们可以看到我们是否使用repr()函数打印字符串然后用一对引号打印,如果我们计算一个值,我们得到的值比str()函数更精确。






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论