Skip to Content
Python 技術手冊 第三版
book

Python 技術手冊 第三版

by lex Martelli, Anna Martelli Ravenscroft, Steve Holden
January 2018
Intermediate to advanced
856 pages
17h 17m
Chinese
GoTop Information, Inc.
Content preview from Python 技術手冊 第三版
613
19
客戶端網路協定模組
Python 的標準程式庫提供了數個模組,來簡化 Internet(網際網路)協
定的使用,特別是在客戶端的(或一些簡單的伺服器)。近來,Python
Package Index
https://pypi.python.org/pypi
PyPI)提供了更多的這種套
件。這些第三方的套件支援非常多樣的協定,而有幾個提供的 API 比標準
程式庫的還要好。當你需要使用標準程式庫沒有的協定,或者標準程式庫
提供的方式你不滿意,請一定要搜尋 PyPI,你很有可能在那裡找到更好的
解決方式。
在本章中,我們涵蓋能為某些網路協定用途提供滿意解法的一些標準程式
庫套件,特別是簡單的協定:如果你編寫的程式碼不需要第三方套件,那
麼你的應用程式或程式庫就很容易安裝到其他機器上。我們也提到了幾個
第三方套件,它們涵蓋了標準程式庫中沒有包含的重要網路協定。本章沒
有涵蓋使用非同步程式設計(asynchronous programming)做法的第三方套
件:要找那種套件,請參閱前面的「asyncio 模組(僅限 v3)」。
對於特定的、很常會用到的 HTTP
1
客戶端和其他的網路資源(例如匿名
FTP 站台)用例,這種最好透過 URL
2
存取的情況,標準程式庫只提
供了複雜、不相容(v2 v3 之間)的支援。因此,對於這種情況,我們
1 HTTP,也就是 Hypertext Transfer Protocol,是 World Wide Web 的核心協定:每個 web
伺服器和瀏覽器都會使用它,而它也成為了今日 ...
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版)

Wes McKinney

Publisher Resources

ISBN: 9789864766819