1

I am trying to convert str variable to UUID type. Online tutorials point to below code

import uuid
delete_uuid = "5d27bf88-f3dd-4e95-89c1-f200c8484b42"
your_uuid_string = uuid.UUID(delete_uuid).hex

print(type(your_uuid_string))

but the output is still of type str. Please guide

0

1 Answer 1

3

If you need to get a UUID object as output you need to remove .hex, as UUID.hex returns a str:

The UUID as a 32-character hexadecimal string.

So, you can use

>>> import uuid
>>> delete_uuid = "5d27bf88-f3dd-4e95-89c1-f200c8484b42"
>>> your_uuid_string = uuid.UUID(delete_uuid)
>>> type(your_uuid_string)
<class 'uuid.UUID'>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.