import base64 str_A = "待加密的字符串AABBCC" eStr_A = base64.b64encode(str_A.encode()) print(eStr_A) # b'5b6F5Yqg5a+G55qE5a2X56ym5LiyQUFCQkND' dStr_A = base64.b64decode(eStr_A).decode() print(dStr_A) # 待加密的字符串AABBCC