问题:
django在将uuid存入数据库时候会将“-”删除,如:“2ac99acd-c8da-4a86-a6f4-f7086d554dde” -> “2ac99acdc8da4a86a6f4f7086d554dde”
解决办法:
import uuid client_uuid = "2ac99acdc8da4a86-a6f4f7086d554dde" client_uuid = uuid.UUID(client_uuid)
扩展问题:
使用 uuid.UUID(client_uuid) 时候传入的client_uuid类型必须是str,若事uuid类型会报错:
File "/usr/local/anaconda3/envs/iam_sit_test/lib/python3.9/uuid.py", line 174, in __init__
hex = hex.replace('urn:', '').replace('uuid:', '')
AttributeError: 'UUID' object has no attribute 'replace'
如下:
解决办法:
client_uuid = uuid.UUID(str(client_uuid))
标签:__,uuid,hex,replace,问题,client,增加,UUID From: https://www.cnblogs.com/LoveMoney-MrLi/p/17083897.html