python:如何将有效的 uuid 从字符串转换为 UUID? [英] python: how to convert a valid uuid from String to UUID?

查看:49
本文介绍了python:如何将有效的 uuid 从字符串转换为 UUID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到的数据是

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

我需要将 uuidString 转换为 uuid

and I need to convert the uuid from String to uuid

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

I did not find a way on the python docs, or am I missing something basic here?

推荐答案

只需将其传递给 uuid.UUID:

import uuid

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

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

这篇关于python:如何将有效的 uuid 从字符串转换为 UUID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆