Sometimes, we want to create a GUID or UUID in Python.
In this article, we’ll look at how to create a GUID or UUID in Python.
How to create a GUID or UUID in Python?
To create a GUID or UUID in Python, we can use the uuid
module.
For instance, we write:
import uuid
id = uuid.uuid4()
print(id)
We call uuid.uuid4
to return a v4 UUID as a string.
Therefore, id
is something like 'c55b58d6-aa0d-498e-96be-433f99492cfb'
.
Conclusion
To create a GUID or UUID in Python, we can use the uuid
module.