1. Base64 Encoding, Decoding Example
1 2 3 4 5 6 7 8 9 10 11 12 13 | import base64 def fileToBase64(filepath): fp = open(filepath, "rb") data = fp.read() fp.close() return base64.b64encode(data).decode('utf-8') def stringToBase64(s): return base64.b64encode(s.encode('utf-8')) def base64ToString(b): return base64.b64decode(b).decode('utf-8') |
댓글 없음:
댓글 쓰기