加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python 数据类型_整数_浮点数

发布时间:2020-12-20 10:36:46 所属栏目:Python 来源:网络整理
导读:? 浮点数 type(1.34) class ‘float‘ 整形 type(10) class ‘int‘ ? 字符行转整形 type(int("123")) class ‘int‘ 整形转字符 type(str(1231)) class ‘str‘ ? 整形转浮点 float(123) 123.0 浮点转整形 丢失精度 int(123.4354353) 123 ? 打印 转义字符

?

浮点数

>>> type(1.34)
<class ‘float‘>

整形
>>> type(10)
<class ‘int‘>

?

字符行转整形

>>> type(int("123"))
<class ‘int‘>

整形转字符

>>> type(str(1231))
<class ‘str‘>

?

整形转浮点

>>> float(123)

123.0

浮点转整形 丢失精度

>>> int(123.4354353)
123

?

打印

转义字符可以转义很多字符,比如n表示换行,t表示制表符,字符本身也要转义,所以表示的字符就是

print(" t n")

>>> print(" t n")

>>>

r?字符串默认不转义

?

print(r" t n")

>>> print(r" t n")
t n

?

布尔

True 和 False

?

>>> True
True


>>> False
False

?



not 取反 相当于!>>> True or True True >>> True or False True >>> False or False False >>> 5 > 3 or 1 > 3 True

>>> not True
False
>>> not False
True

?

and 相等于 &&

>>> True and True
True

>>> True and False
False

?

or 或则 ||

>>> True or True
True
>>> True or False
True

?

?

+ - * /?

除法是//,称为地板除?整数结果

>>> 1 + 12>>> 2 - 11>>> 1 * 33>>> 4 / 22.0>>> 4 // 22

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读