python - decode() missing 1 required positional argument: 'output'
本文介绍了python - 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'
解决方案
使用 base64.b64decode
这篇关于python - decode() missing 1 required positional argument: 'output'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文