Discuss / Python / 测试中稍微改一下下面的assert语句就会出错,不知道哪里有问题。

测试中稍微改一下下面的assert语句就会出错,不知道哪里有问题。

Topic source
    if len(s)%4 == 0:
        return base64.b64decode(s)
    else:
        s = s + len(s) % 4 * b'='
        return base64.b64decode(s)

luowb2004

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

因为assert要对应,不能乱改。下面的是可以的。

assert b'kangaio' == safe_base64_decode(b'a2FuZ2Fpbw=='), safe_base64_decode('a2FuZ2Fpbw==')

assert b'kangaio' == safe_base64_decode(b'a2FuZ2Fpbw'), safe_base64_decode('a2FuZ2Fpbw')

print('ok')


  • 1

Reply