Python Random Function without using random module

后端 未结 6 1069
渐次进展
渐次进展 2021-02-09 17:14

I need to write the function -

random_number(minimum,maximum)

Without using the random module and I did this:

import time

def         


        
6条回答
  •  再見小時候
    2021-02-09 17:45

    Are you allowed to read random data in some special file? Under Linux, the file `/dev/urandom' provides a convenient way to get random bytes. You could write:

    import struct
    f = open("/dev/urandom","r")
    n = struct.unpack("i",f.read(4))[0]
    

    But this will not work under Windows however.

提交回复
热议问题