【发布时间】:2017-04-07 08:52:06
【问题描述】:
我在 python 中有一个字典,其中包含 unicode 值。我想计算这本字典的 md5 和。我尝试使用这个问题的答案:Computing an md5 hash of a data structure
import hashlib
import bencode
data = {'unicode_text': 'سلام'}
data_md5 = hashlib.md5(bencode.bencode(data)).hexdigest()
print data_md5
但问题是bencode返回这个错误:
KeyError: <type 'unicode'>
【问题讨论】:
标签: python dictionary unicode python-unicode