python中str与repr
来源:互联网 发布:家庭网络改造设计方案 编辑:程序博客网 时间:2024/05/17 02:43
(如果没有等价的语法,则会发生SyntaxError 异常) 某对象没有适于人阅读的解释形式的话, str() 会返回与repr()
>>> s = 'Hello, world.'
>>> str(s)
'Hello, world.'
>>> repr(s)
"'Hello, world.'"
>>> str(1.0/7.0)
'0.142857142857'
>>> repr(1.0/7.0)
'0.14285714285714285'
>>> x = 10 * 3.25
>>> y = 200 * 200
>>> s = 'The value of x is ' + repr(x) + ', and y is ' + repr(y) + '...'
>>> print s
The value of x is 32.5, and y is 40000...
>>> # The repr() of a string adds string quotes and backslashes:
... hello = 'hello, world\n'
>>> hellos = repr(hello)
>>> print hellos
'hello, world\n'
>>> # The argument to repr() may be any Python object:
... repr((x, y, ('spam', 'eggs')))
"(32.5, 40000, ('spam', 'eggs'))"
- python中str与repr
- python 中 str() 与 repr() 的区别
- python中str()与repr()的区别
- python中的repr与str
- [python]python中str()与repr()的区别与联系
- Python中str(x) 与``与repr(x)区别
- python str与repr的区别
- python学习 str与repr区别
- Python str() 与 repr() 的区别
- python中str()和repr()区别
- python中repr和 str的异同
- python-str()和 repr()
- Python repr str 函数
- python str()/repr()
- python str, repr
- Python中str()与__str__、repr()与__repr__、eval()、__unicode__的关系与区别
- repr()与str()
- Python 3 str()与repr()、__str__与__repr__:
- PAT B1016. 部分A+B (15)
- viewpager设置缓存的问题
- 排序算法之 快速排序 及其时间复杂度和空间复杂度
- java连接 SQlite数据库
- SQLMap用户手册【超详细】
- python中str与repr
- 夕拾算法进阶篇:11)最长回文子串(Manacher算法)
- java 实体层代码生成器,带注释!!! (补17年1月)
- 欢迎使用CSDN-markdown编辑器
- 跨域请求详解(已采纳)
- 进程/线程模型
- Leetcode029--最小路径和
- 数据结构实验之栈六:下一较大值(二)—栈+动态规划
- jQuery中的DOM操作(一)