Home > Backend Development > Python Tutorial > python 布尔操作实现代码

python 布尔操作实现代码

WBOY
Release: 2016-06-16 08:46:38
Original
1038 people have browsed it

和别的语言布尔类型定义1为真,0为假不同,python定义的真假比较多。
先说下假吧:

false,none,0,"",{},[],()

而真的话,只要和上面的相反就行,比如上面是false,那真为true,[]空列表为假,不为空的列表为真。明白了这些。我们就可以用到python判断语句

如果你要把别的类型转换为bool类型的话,可以通过内置方法bool方法来进行转换。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template