Skip to Content
可编程网络自动化
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
81
>>> 'network' == 'network'
True
>>>
>>> 'network' == 'no_network'
False
>>>
简要地了解布尔对象、运算符和表达式之后,再来看一看如何使用
Python
列表。
4.3.4
 学习使用
Python
列表
在前面讲述字符串内建方法
join()
split()
时,简单介绍过列表。现在来详细地说一说。
列表是类型为
list
的对象,究其根本而言,就是有序的对象序列。这里再次引用先前介绍
join()
方法时用到的例子,快速回顾一下如何创建列表。这些例子全都是字符串列表,但
很快你就会看到,也可以创建任何其他数据类型的列表。
>>> hostnames = ['r1', 'r2', 'r3', 'r4', 'r5']
>>> commands = ['config t', 'interface Ethernet1/1', 'shutdown']
>>>
下面的例子就展示了一个不同数据类型的对象列表。
>>> new_list = ['router1', False, 5]
>>>
>>>
print
(new_list)
['router1', False, 5]
>>>
现在你已经明白列表就是出现在方括号内的有序的对象序列。在使用列表时,最常碰到的
一项任务就是访问列表元素。
让我们来创建一个新的接口列表,演示如何打印出单个列表元素。
>>> interfaces = ['Eth1/1', 'Eth1/2', 'Eth1/3', ...
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

弱监督学习实用指南

弱监督学习实用指南

Wee Hyong Tok, Amit Bahree, Senja Filipi
Python和NLTK实现自然语言处理

Python和NLTK实现自然语言处理

Posts & Telecom Press, Nitin Hardeniya
Go程序设计语言

Go程序设计语言

艾伦A. A.多诺万, 布莱恩W. 柯尼汉
Python机器学习案例精解

Python机器学习案例精解

Posts & Telecom Press, Yuxi (Hayden) Liu

Publisher Resources

ISBN: 9787115606181