擅长:python、mysql、java
<p>如果您能生成不以数字开头的随机散列,那么您所询问的可能是可能的。
因此,以下代码只有在生成的十六进制数字不是以数字开头时才有效</p>
<pre><code>bagel = "bagels"
h = hashlib.md5()
h.update(bagel.encode('utf-8'))
temp = h.hexdigest()
exec("{0} = dict()".format(temp))
</code></pre>
<p>所以,为了使它适用于任何东西,我建议您添加一个常量字符串,如下所示</p>
<pre><code>bagel = "bagels"
h = hashlib.md5()
h.update(bagel.encode('utf-8'))
temp = h.hexdigest()
exec("const_{0} = dict()".format(temp))
</code></pre>