最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Python如何实现强制数据类型转换 Python实现强制数据类型转换代码
时间:2019-11-22 编辑:袖梨 来源:一聚教程网
本篇文章小编给大家分享一下Python实现强制数据类型转换代码,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。
常用转换函数
示例:
pi = 3.14 print('pi:', int(pi)) # pi: 3 pi = 3 print('pi:', float(pi)) # pi: 3.0 complex1 = complex(1, 2) print(complex1) # (1+2j) age = 12 print('该同学今年%s岁了' % str(age)) # 该同学今年12岁了 print(repr('lily')) # "'lily'" x = 8 print(eval('x * 3')) # 24 print(chr(65)) # A print(ord('a')) # 97 print(hex(10)) # 0xa print(oct(10)) # 0o12 print(bin(10)) # 0b1010
相关文章
- Golang ProtoBuf的基本语法详解 10-20
- Python识别MySQL中的冗余索引解析 10-20
- Python+Pygame绘制小球代码展示 10-18
- Python中的数据精度问题介绍 10-18
- Python随机值生成的常用方法介绍 10-18
- python3解压缩.gz文件分析 09-27