You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description: 'Decodes a string of quoted-printable data back to binary.'
4
+
Subjects:
5
+
- 'Computer Science'
6
+
- 'Data Science'
7
+
Tags:
8
+
- 'Encoding'
9
+
- 'Functions'
10
+
CatalogContent:
11
+
- 'learn-python-3'
12
+
- 'paths/computer-science'
13
+
---
14
+
15
+
In Python, the **`.a2b_qp()`**[function](https://www.codecademy.com/resources/docs/python/functions) decodes a string of quoted-printable data back to binary.
16
+
17
+
Quoted-printable is an encoding scheme used in email messages to represent non-ASCII characters using only ASCII characters.
18
+
19
+
## Syntax
20
+
21
+
```pseudo
22
+
binascii.a2b_qp(data, header=False)
23
+
```
24
+
25
+
**Parameters:**
26
+
27
+
-`data`: A bytes-like object containing the quoted-printable encoded data to decode.
28
+
-`header`: When set to `True`, it decodes the data as if it were in an email header, handling special rules for headers. Default is `False`.
29
+
30
+
**Return value:**
31
+
32
+
The `.a2b_qp()` function returns the decoded binary data as a bytes object.
33
+
34
+
## Example
35
+
36
+
This example decodes a quoted-printable encoded byte string into its original binary form:
37
+
38
+
```py
39
+
import binascii
40
+
41
+
# Quoted-printable encoded data
42
+
encoded_data =b'Codecademy=20Docs'
43
+
44
+
# Decode the data back to binary
45
+
decoded_data = binascii.a2b_qp(encoded_data)
46
+
47
+
print(decoded_data)
48
+
```
49
+
50
+
This produces the following output:
51
+
52
+
```shell
53
+
b'Codecademy Docs'
54
+
```
55
+
56
+
## Codebyte Example
57
+
58
+
This example decodes a quoted-printable encoded message body retrieved from an email:
0 commit comments