UUID发送到客户端与str(值),但ib服务器接收回格式错误的十六进制字符串



我在SQLAlchemy中使用uid4作为一列,我得到了16d11d6abdaf4fe9905a56e0be8d15d1这样的值我需要使用json格式发送此id到客户端,并在未来从客户端id接收,并对数据库进行查询。我发送的是

result = {'id': str(id)}
#this is from Tornado handler
self.write(simplejson.dumps(result))

当我从用户json发送id我收到,在服务器上我提取像

data = tornado.escape.json_decode(self.request.body)
id = data.get('id', None)
#also tornado handler when I receive id from client
#I also have tried like uuid.UUID(bytes=id.bytes) but also get error

我总是得到错误的十六进制字符串。如何发送到客户端和从客户端到服务器uuid json ?

第一个:

result = {'id': str(id)}
#If the given chunk is a dictionary, we write it as JSON and set
#the Content-Type of the response to be application/json.
self.write(result)

二:

#Returns the value of the argument with the given name
id = self.get_argument("id")

对不起,我的英语很差

最新更新