Python | os.urandom() method Improve Improve Like Article Like Save Share Report OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality. os.urandom() method is used to generate a string of size random bytes suitable for cryptographic use or we can say this method generates a string containing random characters. Syntax: os.urandom(size) Parameter: size: It is the size of string random bytes Return Value: This method returns a string which represents random bytes suitable for cryptographic use. Example #1 : # Python program to explain os.urandom() method # importing os module import os # Declaring size size = 5 # Using os.urandom() method result = os.urandom(size) # Print the random bytes string # Output will be different everytime print(result) Output: b'\xe2\xaf\xbc:\xdd' Last Updated : 18 Oct, 2019 Like Article Save Article Previous Python | os.umask() method Next Python | Check order specific data type in tuple Share your thoughts in the comments Add Your Comment Please Login to comment... Similar Reads Class Method vs Static Method vs Instance Method in Python Class method vs Static method in Python Difference between Method Overloading and Method Overriding in Python Pandas DataFrame iterrows() Method | Pandas Method Pandas DataFrame interpolate() Method | Pandas Method Pandas DataFrame duplicated() Method | Pandas Method Python Dictionary get() Method Real-Time Edge Detection using OpenCV in Python | Canny edge detection method Python | os._exit() method Python | os.WEXITSTATUS() method Like R Rajnis09 Follow Article Tags : python-os-module Python Practice Tags : python