Python repr() 或str() 函数
来源:互联网 发布:java 线程同步锁 编辑:程序博客网 时间:2024/05/02 00:06
(如果没有等价的语法,则会发生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 repr() 或str() 函数
- Python repr() 或str() 函数
- Python repr() 或str() 函数
- Python repr() 或str() 函数
- Python repr() 或str() 函数
- Python repr() 或str() 函数, 反引号
- Python repr() 或str() 函数, 反引号
- Python repr str 函数
- Python repr() 函数和str() 函数
- Python 的repr() 和str() 函数
- python函数 cmp() type() str() repr()和 ''
- Python内建函数str()和repr()
- Python内建函数str,repr解析
- python的str()和repr()函数比较
- python-str()和 repr()
- python str()/repr()
- python str, repr
- str and repr 函数
- Activity组件启动过程
- C#加密算法汇总(推荐)
- Leetcode117: Add Two Numbers
- SPServer : 一个基于线程池(包括HAHS和LF)的高并发 server 框架
- tomcat配置HTTPS方式
- Python repr() 或str() 函数
- 移动开发博客汇总
- epoll在ET和LT模式下读写
- xUtils
- 移动视频直播点播方案
- Xcode中的iOS模拟器(iOS Simulator)的介绍和使用心得
- 苹果AirPlay浅析
- Android客户端与服务器之间的通信
- storyboard 设置view边框背景