Authentication 从web2py CRYPT()函数返回字符串

Authentication 从web2py CRYPT()函数返回字符串,authentication,encryption,web2py,Authentication,Encryption,Web2py,我正在尝试使用更新我的auth_user表 hash = CRYPT()(password)[0] db(query).update(password=str(hash)) 我一直得到一个TypeError:字符映射必须返回integer、None或unicode,这很奇怪,因为我在另一个函数中做了同样的事情,但没有得到任何错误。 我正在试图理解我在这里做错了什么密码来自哪里?看起来可能是unicode字符串。你可以试试 hash = CRYPT()(password.encode('utf

我正在尝试使用更新我的auth_user表


hash = CRYPT()(password)[0]
db(query).update(password=str(hash))
我一直得到一个TypeError:字符映射必须返回integer、None或unicode,这很奇怪,因为我在另一个函数中做了同样的事情,但没有得到任何错误。
我正在试图理解我在这里做错了什么

密码来自哪里?看起来可能是unicode字符串。你可以试试

hash = CRYPT()(password.encode('utf8'))[0]

添加
type(hash)output
@ZagorulkinDmitry能否更具体一点它打印的是str和repr,终端中的str和repr在调用str(hash)时正好打印我想要的内容。但在我的代码中,它给出了一个错误。