Discuss / Python / 作业

作业

Topic source

Super-String

#1 Created at ... [Delete] [Delete and Lock User]

import base64

def safe_base64_decode(s):
    # 将字符串转换为字节串
    s = s.encode('utf-8')



    # 将字符串长度补齐为 4 的倍数
    s += b'=' * (4 - len(s) % 4)



    # 进行 base64 解码
    return base64.b64decode(s)

  • 1

Reply