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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

可编程网络自动化

可编程网络自动化

Jason Edelman, Scott S. Lowe, Matt Oswalt
Python实用技能学习指南

Python实用技能学习指南

Posts & Telecom Press, Robert Smallshire, Austin Bingham
量子计算机编程:从入门到实践

量子计算机编程:从入门到实践

Eric R. Johnston, Nicholas Harrigan, Mercedes Gimeno-Segovia
Python编程入门与实战

Python编程入门与实战

Posts & Telecom Press, Fabrizio Romano

Publisher Resources

ISBN: 9787115586223