速记Python布尔值
作者:dymlnet 时间:2022-04-23 10:02:17
在python中。布尔值有 Ture False 两种。Ture等于对,False等于错。要注意在python中对字母的大小写要求非常严格。 Ture 和 False 的首字母都要大写。
而布尔值可以互相运算,用 and not or (全部小写)来运算。
and 是与运算,
>>> Ture and Ture
Ture
>>> False and Ture
False
>>> False and False
False
在 and 运算中,只有全部为 Ture 时结果才为 Ture 。反之为 False 。
or 是或运算,
>>> Ture or Ture
Ture
>>> Ture or False
Ture
>>> False or False
False
在 or 运算中,只要有一个是 Ture 那么结果就为 Ture 。
not 运算是非运算,
>>> not Ture
False
>>> not False
Ture
>>> not 1<2
Ture
非运算是单目运算符,顾名思义将 Ture 和 False 互相转换。
来源:http://www.cnblogs.com/dymlnet/p/7764291.html
标签:python,布尔值
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python利用Django如何写restful api接口详解
2022-11-16 13:26:32
![](https://img.aspxhome.com/file/2023/0/98830_0s.jpg)
Numpy中Meshgrid函数基本用法及2种应用场景
2023-05-11 20:13:21
![](https://img.aspxhome.com/file/2023/3/101203_0s.jpg)
python字符串编码识别模块chardet简单应用
2021-10-03 15:09:57
Python实现批量识别图片文字并存为Excel
2021-07-28 06:34:23
![](https://img.aspxhome.com/file/2023/8/66838_0s.jpg)
pandas分别写入excel的不同sheet方法
2022-08-27 04:15:03
详解php中反射的应用
2023-11-15 01:26:56
css+JavaScript实现PDF、ZIP、DOC链接的标注
2007-05-11 17:03:00
Python随机生成数模块random使用实例
2022-08-04 21:04:48
Python+Opencv识别两张相似图片
2022-11-07 09:12:55
![](https://img.aspxhome.com/file/2023/0/97070_0s.jpg)
恢复master..xp_logattach(log explorer)
2010-07-01 19:19:00
深入理解Python单元测试unittest的使用示例
2022-03-18 04:51:00
![](https://img.aspxhome.com/file/2023/2/92412_0s.png)
Python3.5 Pandas模块之Series用法实例分析
2022-07-23 16:19:09
![](https://img.aspxhome.com/file/2023/1/76181_0s.png)
Python实现读取字符串按列分配后按行输出示例
2023-08-07 19:39:14
React TypeScript 应用中便捷使用Redux Toolkit方法详解
2023-08-11 09:48:21
![](https://img.aspxhome.com/file/2023/6/55976_0s.jpg)
Django模板之基本的 for 循环 和 List内容的显示方式
2021-09-24 05:18:24
![](https://img.aspxhome.com/file/2023/7/72867_0s.jpg)
Pycharm没有报错提示(误触ignore)的完美解决方案
2023-01-24 13:39:34
![](https://img.aspxhome.com/file/2023/0/92360_0s.png)
MySQL的性能调优工具:比mysqlreport更方便的tuning-primer.sh
2008-12-08 08:37:00
python 写的一个爬虫程序源码
2022-08-10 16:00:47
asp #include file 与 #include virtual 的区别小结第1/2页
2011-04-02 11:17:00
python读取json数据还原表格批量转换成html
2023-11-19 05:46:20