9

Python中True和False的含义.md

 3 years ago
source link: https://wetts.github.io/2019/11/20/%E8%AF%AD%E8%A8%80/Python/%E5%85%B6%E4%BB%96/Python%E4%B8%ADTrue%E5%92%8CFalse%E7%9A%84%E5%90%AB%E4%B9%89/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Python中True和False的含义.md

2019-11-20Python

在 Python 中,整数 0 代表假,整数 1 代表真。不过,除此之外,Python 也把任何空数据结构视为假,把任何非空数据结构视为真。更一般地,真和假的概念是 Python 中每个对象的固有属性:每个对象非真即假。

  • 数字如果等于零则为假,反之则为真。
  • 其他对象如果为空则为假,反之则为真。
  • 空字符串、空列表、空字典都为假。
  • None 为假。

Gitalking ...


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK