Skip to Content
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
Explore Skills
Cloud Computing
Microsoft Azure
Amazon Web Services (AWS)
Google Cloud
Cloud Migration
Cloud Deployment
Cloud Platforms
Data Engineering
Data Warehouse
SQL
Apache Spark
Microsoft SQL Server
MySQL
Kafka
Data Lake
Streaming & Messaging
NoSQL Databases
Relational Databases
Data Science
Pandas
R
MATLAB
SAS
D3
Power BI
Tableau
Statistics
Exploratory Data Analysis
Data Visualization
AI & ML
Generative AI
Machine Learning
Artificial Intelligence (AI)
Deep Learning
Reinforcement Learning
Natural Language Processing
TensorFlow
Scikit-Learn
Hyperparameter Tuning
MLOps
Programming Languages
Java
JavaScript
Spring
Python
Go
C#
C++
C
Swift
Rust
Functional Programming
Software Architecture
Object-Oriented
Distributed Systems
Domain-Driven Design
Architectural Patterns
IT/Ops
Kubernetes
Docker
GitHub
Terraform
Continuous Delivery
Continuous Integration
Database Administration
Computer Networking
Operating Systems
IT Certifications
Security
Network Security
Application Security
Incident Response
Zero Trust Model
Disaster Recovery
Penetration Testing / Ethical Hacking
Governance
Malware
Security Architecture
Security Engineering
Security Certifications
Design
Web Design
Graphic Design
Interaction Design
Film & Video
User Experience (UX)
Design Process
Design Tools
Business
Agile
Project Management
Product Management
Marketing
Human Resources
Finance
Team Management
Business Strategy
Digital Transformation
Organizational Leadership
Soft Skills
Professional Communication
Emotional Intelligence
Presentation Skills
Innovation
Critical Thinking
Public Speaking
Collaboration
Personal Productivity
Confidence / Motivation
Features
All features
Verifiable skills
AI Academy
Courses
Certifications
Interactive learning
Live events
Superstreams
Answers
Insights reporting
Radar Blog
Buy Courses
Plans
Sign In
Try Now
O'Reilly Platform
book
Python语言及其应用(第2版)
by
Bill Lubanovic
March 2022
Intermediate to advanced
522 pages
13h 52m
Chinese
Posts & Telecom Press
Content preview from
Python语言及其应用(第2版)
20
|
第
2
章
数和程序)全都包装成了
对象
。本书用了整整一章(参见第
10
章)来介绍如何在
Python
中自定义对象。目前,我们只讨论处理基本内建数据类型的对象。
使用内存架子作类比,可以将对象想象成变量大小的盒子,其占据了架子上的部分空间,
如图
2-1
所
示。
Python
会生成这些对象盒子,并将其放入架子的空闲区域,用不着时就将
它们移走。
图
2-1
:对象就像一个盒子,这个盒子是值为
7
的整数
在
Python
中,对象是至少包含以下内容的数据块:
•
类型
,定义了可以执行什么操作(参见下一节);
•
唯一的
id
,用于区分其他对象;
•
与类型一致的
值
;
•
引用计数
,用于跟踪该对象的使用频率。
id
就像在架子上的位置,这是一个唯一的标识符。
类型
就像盒子上的工厂印章,说明其用
途。如果某个
Python
对
象是整数,则类型为
int
,可以与另一个
int
类型的对象相加(还
有其他操作,第
3
章会介绍)
。如果把盒子画成透明塑料材质的,就可以看到里面的
值
。
随后讲到变量和名称的时候,你会学到
引用计数
的用法。
2.2
类型
表
2-1
展示了
Python
的基本数据类型。第
2
列(类型)包含了
Python
的类型名称。第
3
列(可变?)指明了值在创建后是否能被改动,对此下一节会详细解释。第
4
列
(示例)
展示了对应类型的一些例子。最后一列(章)指出本书哪一章详细讲解了该类型。
表
2-1
:
Python
的基本数据类型
名称
类型
可变
?
示例
章
布尔值
bool
否
True, False
第
3
章
整数
int
否
47, 25000, 25_000
第
3
章
浮点数
float ...
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编程入门与实战
Posts & Telecom Press, Fabrizio Romano
Python实用技能学习指南
Posts & Telecom Press, Robert Smallshire, Austin Bingham
Python技术基础视频教程
保罗·J·戴特尔
Python面向对象编程指南
Posts & Telecom Press, Steven F. Lott
Publisher Resources
ISBN: 9787115586223