Generate random UUID in Python

Hello friends, in this tutorial I will tell you how to generate random UUID in Python.

Generate random UUID in Python

Before going ahead, make sure to import the uuid library into your code.

import uuid

I have used the uuid4 function to get a random universal unique identifier. I have used this function because it does not consider MAC addresses like the uuid1() function. This ensures privacy and guarantees a random ID.

Code :

my_id = uuid.uuid4()
print(my_id)

Output :

bf165b4d-0869-4085-a96e-8058379d3030

Leave a Reply

Your email address will not be published. Required fields are marked *