Import RandomImport StringPrint (Random.randint (1, 199)) # [1,199] randomly take an integer s = Random.choice ([' qwe ', ' wer ', ' ert ') # Randomly take an element Print (s) print (string.digits)# All the numbers 0-9Print (String.ascii_lowercase)# all lowercase lettersPrint (String.ascii_uppercase)# all uppercase lettersPrint (string.ascii_letters)# All lowercase letters + all uppercase lettersPrint (string.punctuation)# All the special charactersres = Random.sample (string.digits,3) # randomly fetch n elements Print (res) print (". Join (RES))res = Random.uniform (1, 9) # take random decimals Print (RES) print (round (res),2) # Keep Several decimal places, if after rounding, the last decimal number is 0 does not show the last Print (Random.random ())# Take a random decimal between 0-1s = [' A ', ' B ', ' C ', ' d ', ' e '] Random.shuffle (s)# random Shuffle orderPrint (s)
python--Random Number Module