Skip to Content
Python语言及其应用(第2版)
book

Python语言及其应用(第2版)

by Bill Lubanovic
March 2022
Intermediate to advanced
522 pages
13h 52m
Chinese
Posts & Telecom Press
Content preview from Python语言及其应用(第2版)
30
3
分隔的输入
参数
,返回
0
个或多个值即可。
bool()
函数可以接受任何值作为参数并返回等
价的布尔值。
非零的数被视为
True
>>> bool(True)
True
>>> bool(1)
True
>>> bool(45)
True
>>> bool(-45)
True
值为
0
的数被视为
False
>>> bool(False)
False
>>> bool(0)
False
>>> bool(0.0)
False
4
章会介绍布尔值的用途。在后续章节中,你会看到如何将列表、字典和其他类型评估
True
False
3.2
整数
整数就是既没有分数也没有小数点的数字。好吧,除了可能的前缀符号。另外还有基数,
如果你想用惯常的十进制(基数为
10
)之外的方式表示。
3.2.1
字面整数
Python
中,
字面整数
就是任意的数位序列:
>>> 5
5
单独的
0
同样有效:
>>> 0
0
但是数位
1
9
之间不能有
0
>>> 05
File "<stdin>", line 1
05
^
SyntaxError: invalid token
数字
31
这个
Python
异常
警告你输入的内容违反了
Python
的规则。
3.2.5
节会解释这
意味着什么。你将在本书中看到更多的异常例子,因为这是
Python
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python编程入门与实战

Python编程入门与实战

Posts & Telecom Press, Fabrizio Romano
Python实用技能学习指南

Python实用技能学习指南

Posts & Telecom Press, Robert Smallshire, Austin Bingham
Python技术基础视频教程

Python技术基础视频教程

保罗·J·戴特尔
Python面向对象编程指南

Python面向对象编程指南

Posts & Telecom Press, Steven F. Lott

Publisher Resources

ISBN: 9787115586223