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
111
使用
sys.argv
时,仍然需要考虑错误处理(至少也得检查一下列表长度)。
除此之外,脚本用户必须知道传入脚本的元素的准确顺序。对于更高级的参
数处理,可以考虑
Python
模块
argparse
,它提供了一种非常直观的方式来
传递带有“标志”的参数,并且有一个内置的帮助菜单。不过该模块超出了
本书的范畴。
4.12
 使用
pip
与安装
Python
随着开始使用
Python
,你可能需要安装由
Python
编写的其他软件。例如,使用
netmiko
(一款流行的适用于
Python
SSH
客户端
,第
7
章会介绍)测试网络设备自动化。包括
netmiko
在内的
Python
软件通常都是用
Python
包索引
Python Package Index
PyPI
,读作
pie-pie
)发布的。
对于托管在
PyPI
的任何
Python
软件(如
netmiko
),都可以使用
pip
程序将其直接从
PyPI
安装到本地主机。安装工具
pip
默认从
PyPI
下载软件并安装。
Linux
主机上,使用
pip
安装
netmiko
只需要一行代码。
ntc@ntc:~$ sudo pip install netmiko
# 略去输出
该命令会将
netmiko
安装在系统路径指定的位置(视具体的操作系统而定)。
在默认情况下,会安装指定
Python
包的最新稳定版
。但是,有时候你可能想安装特定版本
(避免在未经测试前自动安装新版)。这称为
钉包
。你可以指定安装某个版本。下面的例子
展示了如何安装
1.4.2
版本的
netmiko ...
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