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 技術手冊 第三版
676
|
21 章 EmailMIME 與其他網路編碼
將二進位資料編碼為 ASCII 文字
有數種媒體(例如電子郵件訊息)只能含有 ASCII 文字。當你想要透過這
種媒體傳送任意的二進位資料,你就得將那些資料編碼為 ASCII 文字字
串。Python 標準程式庫提供了模組支援標準的編碼,例如 Base64Quoted
Printable UU
base64 模組
base64
模組支援 RFC 3548 中規範的編碼 Base16Base32 Base64。這些
編碼中每個都是將任意二進位資料表示為 ASCII 文字的簡潔方式,而不會
嘗試產生人類可讀的結果。
base64
提供 10 個函式:Base64 的有 6 個,加
Base32 Base16 2 個。那 6 Base64 函式為:
b64decode b64decode(s,altchars=None, validate=False)
解碼 Base64 所編碼的位元組字串
s
,並回傳解碼後的位元組字
串。
altchars
,若不為
None
,就必須是至少兩個字元(其餘的字元
會被忽略)的一個位元組字串,指定兩個非標準的字元用來取代
+
/
(可用來處理具 URL 安全性或檔案系統安全性的 Base64
碼字串)。
validate
只能在 v3 中傳入:若為
True
,當
s
含有的任
何位元組不是有效的 Base64 編碼字串,此呼叫會提出一個例外
(預設情況中,這種位元組單純會被忽略並跳過)。如果
s
沒有依
Base64 ...
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

測試驅動開發|使用 Python

Harry J.W. Percival

Publisher Resources

ISBN: 9789864766819