Import random # print (random. random () #0-1 does not include 1 random floating point print (random. randint () #1-10 contains the print (random. randrange () #1-10 contains 1 and does not include 10 integers print (random. sample (["AAA", ["A", "B"], 3, 4, 5], 2 )) # specify a range and specify the required random number. ls = ["1", "2", "3", "4"] Random. shuffle (LS) # print (LS) print (random. choice ([1, 2, 3]) # randomly select a print (random. choices ([1, 2, 3, 4, 5, 6, 7], K = 2) # random selection of the specified number # Random verification code length custom including 0-9 A-Z A-zdef get_auth_code (length): res = "" For I in range (length): A = random. randint (0, 9) B = CHR (random. randint (65,90) c = CHR (random. randint (97,122) S = random. choice ([a, B, c]) RES + = STR (s) return resprint (get_auth_code (4) # result: 4 random values of [0-9 A-Z A-Z] print (random. uniform (1, 3) # returns a floating point number between A and B. If A> B, it is the floating point number between B and. Both A and B may appear in the result.
Random Number Module