gpt4 book ai didi

python:如何将有效的 uuid 从 String 转换为 UUID?

转载 作者:IT老高 更新时间:2023-10-28 21:37:30 24 4
gpt4 key购买 nike

我收到的数据是

   {
"name": "Unknown",
"parent": "Uncategorized",
"uuid": "06335e84-2872-4914-8c5d-3ed07d2a2f16"
},

我需要将 uuidString 转换为 uuid

我在 python docs 上没有找到方法,还是我在这里遗漏了一些基本的东西?

最佳答案

只需将其传递给 uuid.UUID:

import uuid

o = {
"name": "Unknown",
"parent": "Uncategorized",
"uuid": "06335e84-2872-4914-8c5d-3ed07d2a2f16"
}

print uuid.UUID(o['uuid']).hex

关于python:如何将有效的 uuid 从 String 转换为 UUID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15859156/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com