【发布时间】:2018-07-23 20:54:32
【问题描述】:
这是我的代码,
if __name__ == "__main__":
key = "0123456789abcdef0123456789abcdef".decode('hex') /this line is having error
plain_1 = "1weqweqd"
plain_2 = "23444444"
plain_3 = "dddd2225"
print(plain_1)
print(plain_2)
print(plain_3)
cipher = Present(key)
输出
AttributeError: 'str' object has no attribute 'decode'
【问题讨论】:
-
str在 Python 2 中有 decode 方法,但在 Python 3 中没有。 -
使用:
binascii.unhexlify('0123456789abcdef0123456789abcdef') -
这里有人遇到过类似问题:stackoverflow.com/questions/3283984/…
-
你想解码十六进制数字并且你试图解码字符串我认为这可能是问题。
标签: python algorithm encryption