一起来学习一下python的数字类型
作者:奔跑的蜗牛—平静从我开始 时间:2023-03-10 05:28:30
int 数字
python 有3种数字类型
int: 整数类型
float: 浮点类型
complex: 复数类型
int类型
#Int或整数是完整的数字,正数或负数,没有小数,不限制长度
a = 10
b = -10
c = 4555555555555555555555
print(">>Int或整数是完整的数字,正数或负数,没有小数,不限制长度")
print(type(a),type(b),type(c))
print(a, b, c)
Float类型
#Float:浮动或浮点数是包含小数的正数或负数,不限制长度
d = 12.00
e = -12.21
f = 4555555555555.58
print(">>浮动或浮点数是包含小数的正数或负数,不限制长度")
print(type(d),type(e),type(f))
print(d, e, f)
complex类型
#complex 复数用'j'作为虚部编写
g = 2+3j
h = 7j
i = -7j
print(">>complex 复数用'j'作为虚部编写 ")
print(type(g),type(h),type(i))
print(g, h, i)
int(),float(),complex()类型之间的转换
j = 12
k = 12.63
l = 3j
print('>>int,float,complex类型之间的转换 ')
print('>> 转成int')
print(int(k))
#print(int(l)) 复数转换为int会报错
print('>> 转成flaot')
print(float(j))
#print(float(l)) 复数转换为float会报错
print('>>转成complex')
print(complex(k))
print(complex(j))
来源:https://blog.csdn.net/weixin_38931408/article/details/122695646
标签:python,数字,类型
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
deepin20.1系统安装MySQL8.0.23(超详细的MySQL8安装教程)
2024-01-25 14:26:21
![](https://img.aspxhome.com/file/2023/6/77316_0s.png)
通过js获取上传的图片信息(临时保存路径,名称,大小)然后通过ajax传递给后端的方法
2024-04-17 10:06:38
sqlserver服务器验证改为混合验证模式步骤
2024-01-20 18:02:28
![](https://img.aspxhome.com/file/2023/7/110957_0s.jpg)
实例讲解python中的协程
2022-08-10 20:10:38
细化解析:SQL Server 2005 数据库镜像
2009-01-23 13:41:00
深入浅出SQL之左连接、右连接和全连接
2009-08-30 15:14:00
ES6入门教程之let和const命令详解
2024-05-22 10:37:07
tensorflow识别自己手写数字
2022-10-12 20:25:04
![](https://img.aspxhome.com/file/2023/1/99431_0s.jpg)
python 爬取壁纸网站的示例
2022-07-10 13:29:54
![](https://img.aspxhome.com/file/2023/8/87978_0s.png)
python 划分数据集为训练集和测试集的方法
2023-01-10 12:18:36
python 性能优化方法小结
2022-08-04 21:13:43
![](https://img.aspxhome.com/file/2023/4/101114_0s.png)
python用fsolve、leastsq对非线性方程组求解
2021-06-28 23:33:29
Python计算机视觉里的IOU计算实例
2021-12-07 18:15:10
Python IDE PyCharm的基本快捷键和配置简介
2021-09-18 07:08:10
![](https://img.aspxhome.com/file/2023/3/112143_0s.png)
基于Python数据可视化利器Matplotlib,绘图入门篇,Pyplot详解
2022-11-20 07:59:16
![](https://img.aspxhome.com/file/2023/7/99167_0s.jpg)
Linux添加Python path方法及修改环境变量的三种方法
2021-03-26 12:22:45
Spring MVC 框架搭建配置方法及详解
2024-03-13 19:04:36
Python使用future处理并发问题方案详解
2022-12-10 18:16:53
JS原生轮播图的简单实现(推荐)
2024-04-29 14:06:30
python使用cookie库操保存cookie详解
2022-09-24 09:33:58