파이썬[Python]: base64 - decodebytes 함수
파이썬(Phthon): base64 모듈 - decodebytes 함수(function)
/// 설명
Base64를 사용하여 바이트 객체를 디코딩합니다.
※ 형식
base64.decodebytes(bytes)
reference
https://docs.python.org/3/library/base64.html#module-base64
※ 형식
base64.decodebytes(bytes)
reference
https://docs.python.org/3/library/base64.html#module-base64
/// 예제
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | from base64 import * test_str = 'Encode the bytes-like object s, \ which can contain arbitrary binary data, and \ return bytes containing the base64-encoded data, \ with newlines (b\'\\n\') inserted after every 76 bytes \ of output, and ensuring that there is a trailing \ newline, as per RFC 2045 (MIME).' test_bytes = bytes(test_str, 'utf-8') # encoding test_encode = encodebytes(test_bytes) print('Original string:', test_str) # Original string: Encode the bytes-like object s, which can contain arbitrary binary data, and return bytes containing the base64-encoded data, with newlines (b'\n') inserted after every 76 bytes of output, and ensuring that there is a trailing newline, as per RFC 2045 (MIME). print('Bytes :', test_bytes) # Bytes : b"Encode the bytes-like object s, which can contain arbitrary binary data, and return bytes containing the base64-encoded data, with newlines (b'\\n') inserted after every 76 bytes of output, and ensuring that there is a trailing newline, as per RFC 2045 (MIME)." print('Base64 encoded :', test_encode) # Base64 encoded : b'RW5jb2RlIHRoZSBieXRlcy1saWtlIG9iamVjdCBzLCB3aGljaCBjYW4gY29udGFpbiBhcmJpdHJh\ncnkgYmluYXJ5IGRhdGEsIGFuZCByZXR1cm4gYnl0ZXMgY29udGFpbmluZyB0aGUgYmFzZTY0LWVu\nY29kZWQgZGF0YSwgd2l0aCBuZXdsaW5lcyAoYidcbicpIGluc2VydGVkIGFmdGVyIGV2ZXJ5IDc2\nIGJ5dGVzIG9mIG91dHB1dCwgYW5kIGVuc3VyaW5nIHRoYXQgdGhlcmUgaXMgYSB0cmFpbGluZyBu\nZXdsaW5lLCBhcyBwZXIgUkZDIDIwNDUgKE1JTUUpLg==\n' print('-' * 100) # decoding test_decode = decodebytes(test_encode) print('Base64 decoded :', test_decode) # Base64 decoded : b"Encode the bytes-like object s, which can contain arbitrary binary data, and return bytes containing the base64-encoded data, with newlines (b'\\n') inserted after every 76 bytes of output, and ensuring that there is a trailing newline, as per RFC 2045 (MIME)." | cs |
* 실행환경: Microsoft Windows 10 Homes
* 인터프리터: 파이썬(Python 3.9)
– 당신을 응원합니다. –
댓글
댓글 쓰기