decode() missing 1 required positional argument: 'output'

部分代码:

#接受数据:
print(s.recv(1024).decode('utf-8'))

data=s.recv(1024)

def decode_base64(data):
    """Decode base64, padding being optional.

    :param data: Base64 data as an ASCII byte string
    :returns: The decoded byte string.

    """
    missing_padding = len(data) % 4
    if missing_padding != 0:
        data += b'='* (4 - missing_padding)
    return base64.decode(data.decode(encoding='utf-8'))
print (decode_base64(data))

返回信息:

Input command:2015$201520150527103546679209$B101|9011|0|1019909081|1
MCQkMXwxMDE5OTA5MDgxLOmfqeilv+i/niMsRuWMuue/oOWzsOi3r+S4nOaAoeWSjOWutuWbrTXluaIxMjA15a6kLEhCSDAwLDAzLDAuMDAsMC4wMCwwLjAwLDQ5Ljg4
Traceback (most recent call last):
  File "E:\Py\20160809.py", line 36, in <module>
    print (decode_base64(data))
  File "E:\Py\20160809.py", line 35, in decode_base64
    return base64.decode(data.decode(encoding='utf-8'))
TypeError: decode() missing 1 required positional argument: 'output'
阅读 11.1k
1 个回答

使用 base64.b64decode

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题