Import Random
# Print (Random.random ()) #浮点数, 0-1, cannot specify range
# Print (Random.uniform (1,5)) #浮点数, 1-5
# Print (Random.randint (1,100)) #1-99 random
# Print (Random.randrange (1,5)) #1-4 random
# Print (Random.choice (' Hello ')) #取1位
# Print (random.sample (' Hello ', 2)) #随机取2位
# x=[1,2,3,4,5,6]
# Print (x)
# Print (Random.shuffle (x)) #随机序列
1Checkcode="' #just started to empty2 3 forIinchRange (4):#0-3, polling 4 times, equivalent to the verification code length 4 bits4Bit=random.randrange (0,4)#Random number 0-35 ifBit==i:#if the random number that happens to be out of the 1th time is also 16TMP=CHR (Random.randint (65,90))#the random number is converted to ASCII code A-Z,65=A,90=Z7 Else:8Tmp=random.randint (0,9)#if the random number that happens to be out of the 1th time is not 1, then randomly generate 0-9 random numbers .9CHECKCODE+=STR (TMP)#The if statement polls 4 times, assigning the value of TMP to checkcode each timeTen One Print(Checkcode) A #9zm9
The programming idea is too TM important!!!
Random module generates verification code for mobile phone