我有这个代码,但是我不明白为什么我会得到这个错误:
a= name+pw+salt
TypeError: unsupported operand type(s) for +: '_sre.SRE_Match' and '_sre.SRE_Match'脚本
class MainHandler(Handler):
def make_salt(self):
return ''.join(random.choice(string.ascii_letters) for x in range(5))
def make_pw_hash(self, name, pw):
salt = self.make_salt()
a= name+pw+salt //problem here
h = hashlib.sha256(a.encode("UTF8")).hexdigest()
return '%s|%s' % (h, salt)
def post(self):
store_hash_and_salt = self.make_pw_hash("José", "somePass")
print (store_hash_and_salt)发布于 2012-05-13 01:48:32
问题不在这里。在前面的某个地方,您传递了RE匹配结果,而不是使用group()方法从结果中获取字符串。
(此外,返回字符串的格式不正确,但这不是这里的bug。)
https://stackoverflow.com/questions/10566038
复制相似问题