Discuss / Python / 作业

作业

Topic source

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

import base64

def safe_base64_decode(s):

    l = len(s)

    t = l % 4

    while t > 0:

        s += '='

        t -= 1

    return base64.b64decode(s)

# 测试:

assert b'abcd' == safe_base64_decode('YWJjZA=='), safe_base64_decode('YWJjZA==')

assert b'abcd' == safe_base64_decode('YWJjZA'), safe_base64_decode('YWJjZA')

print('ok')


  • 1

Reply