The randbytes
method of the random
module is used to generate bytes of the given size. This method was introduced in Python
(version 3.9).
randbytes(n)
n
: The size of bytes that we generate.The method returns bytes of size n
.
import randomno_of_bytes = 5rand_bytes = random.randbytes(no_of_bytes)print(rand_bytes)
random
module.no_of_bytes
.randbytes
passing the value for n
as no_of_bytes
.