W3docs

How to create a GUID/UUID in Python

You can use the uuid module in Python to generate a globally unique identifier (GUID), also known as a universally unique identifier (UUID).

You can use the uuid module in Python to generate a globally unique identifier (GUID), also known as a universally unique identifier (UUID). Here is an example of how to generate a UUID in Python:

Generate a random uuid in Python

python— editable, runs on the server

<div class="alert alert-info flex not-prose"> Watch a course <span class="hidden md:block">Watch a video course </span> Python - The Practical Guide</div>

You can also use the uuid1() function to generate a UUID based on the host ID and current time:

Generate a uuid based on host ID and current time in Python

python— editable, runs on the server

You can also use uuid3() and uuid5() to create UUIDs based on the MD5 and SHA-1 hash respectively, with an additional namespace.

Generate a uuid based on the MD5 and SHA-1 hash respectively, with an additional namespace in Python

python— editable, runs on the server