Skip to Content
流畅的Python(第2版)
book

流畅的Python(第2版)

by Luciano Ramalho
April 2023
Intermediate to advanced
769 pages
25h 16m
Chinese
Posts & Telecom Press
Content preview from 流畅的Python(第2版)
17
2
丰富的序列
你可能已经注意到了,前面几种操作对文本、列表和表格的处理方式没有差异。
文本、列表和表格统称“行列”。……
FOR
命令同样可处理行列。
——
Leo Geurts
Lambert Meertens
Steven Pembertonm
ABC Programmer’s Handbook
,第
8
Python
诞生以前
Guido
ABC
语言贡献过代码。
ABC
语言是一个历时
10
年的研究
项目,旨在设计一种适合初学者的编程环境。现在看来,
ABC
言中的很多理念比较符合
Python
风格
,例如对各种序列一视同仁、内置元组和映射类型、源码结构通过缩进实现、
无须声明变量的强类型等。可见,
Python
对用户友好的特点是有渊源的。
Python
ABC
语言继承了对序列的统一处理方式
。字符串、列表、字节序列、数组、
XML
元素和数据库查询结果
,这些序列在操作上有很多共通之处,都可以迭代、切片、
排序和拼接。
深入理解
Python
中不同的序列类型
,不但能避免重新发明轮子,还可以从它们共通的接口
上受到启发,在自己实现
API
时合理支持及利用现有和将来可能添加的序列类型。
本章讨论的内容大多适用于一般意义上的序列,从我们熟悉的
list
,到
Python 3
新增的
str
bytes
。本章重点讲解列表、元组、数组和队列,
Unicode
字符串和字节序列相关的
话题在第
4
章探讨
。另外,本章关注的是
Python
中现成可用的序列类型,自己创建序列类
型是第
12
章的话题。
本章主要涵盖以下内容:
列表推导式和生成器表达式基础知识; ...
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

Python高级编程(第2版)

Python高级编程(第2版)

Posts & Telecom Press, Michał Jaworski, Tarek Ziadé
Python贝叶斯分析(第2版)

Python贝叶斯分析(第2版)

Posts & Telecom Press, Osvaldo Martin
高效能PYTHON程式設計

高效能PYTHON程式設計

Micha Gorelick, Ian Ozsvald

Publisher Resources

ISBN: 9787115612366