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
可编程网络自动化
by
Jason Edelman
,
Scott S. Lowe
,
Matt Oswalt
January 2023
Intermediate to advanced
458 pages
14h 16m
Chinese
Posts & Telecom Press
Content preview from
可编程网络自动化
在网络场景中学习
Python
|
89
称,如下例所示。
>>>
for
my_attribute, my_value,
in
device.items():
...
print
(my_attribute + ': ' + my_value)
...
os : 12.1
hostname : router1
vendor : juniper
cpu : 5%
memory : 10%
>>>
我们现在已经介绍了
Python
的主要数据类型。你应该很好地理解了字符串、数字、布尔值、
列表以及字典的用法。接下来将继续简要地介绍两种比较高级的数据类型:集合和元组。
4.3.6
学习
Python
集合与元组
这两种数据类型并不是非要在介绍
Python
的时候涉及,但正如本章在开始时说过的那样,
这么做是出于完整性的考虑。下面“登场”的数据类型是
set
和
tuple
。
如果你理解了列表,就能理解集合。集合就是元素的列表,但集合中的特定元素只能有一
个,额外的元素无法被索引(或者说无法像列表那样通过索引值访问)。
可以看到集合形似列表,但是出现在
set()
内。
>>> vendors = set(['arista', 'cisco', 'arista', 'cisco', 'juniper', 'cisco'])
>>>
上例中创建的集合包含了多个相同的元素。在使用
count()
统计列表中的特定厂商出现了
多少次的时候用到过类似的例子。但如果只想知道有多少家厂商以及这些厂商都是哪些的
话,该怎么办?可以使用集合。
>>> vendors ...
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和NLTK实现自然语言处理
Posts & Telecom Press, Nitin Hardeniya
Go程序设计语言
艾伦A. A.多诺万, 布莱恩W. 柯尼汉
弱监督学习实用指南
Wee Hyong Tok, Amit Bahree, Senja Filipi
Python实用技能学习指南
Posts & Telecom Press, Robert Smallshire, Austin Bingham
Publisher Resources
ISBN: 9787115606181