python3解码base64_如何在python3中解码base64

I have a base64 encrypt code, and I can't decode in python3.5

import base64

code = "YWRtaW46MjAyY2I5NjJhYzU5MDc1Yjk2NGIwNzE1MmQyMzRiNzA" # Unencrypt is 202cb962ac59075b964b07152d234b70

base64.b64decode(code)

Result:

binascii.Error: Incorrect padding

But same website(base64decode) can decode it,

Please anybody can tell me why, and how to use python3.5 decode it?

Thanks

解决方案

Base64 needs a string with length multiple of 4. If the string is short, it is padded with 1 to 3 =.

import base64

code = "YWRtaW46MjAyY2I5NjJhYzU5MDc1Yjk2NGIwNzE1MmQyMzRiNzA="

base64.b64decode(code)

# b'admin:202cb962ac59075b964b07152d234b70'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值