randomjavascript
import random
random.random()
a=random.randint(1,3)
b=random.randint(1,3)
c=random.randint(1,3)
print(a,b,c)
e=random.choice('hello')
f=random.choice('hello')
g=random.choice('hello')
print(e,f,g)
seq1=random.sample('hello',2)
seq2=random.sample('hello',2)
seq3=random.sample('hello',2)
print(seq1,seq2,seq3)
ls1=[1,2,3,4,5,6]
random.shuffle(ls1)
print(ls1)
checkcode=''
for i in range(4):
current=random.randint(0,9)
checkcode+=str(current)
print(checkcode)
import random
checkcode1='' # 验证码寄存
for i in range(0,3): #三次 产生三组验证码,检验是否能生成
for i in range (4):#执行次,产生4个随机字符
current=random.randrange(0,4)#随机深沉一个数字和
if current == i: # 用随机数和循环次数猜
tmp=chr(random.randint(65,90))# 猜中了几生成一个字符
else:
tmp=random.randint(0,9)# 没有猜中就生成一个数字
checkcode1+=str(tmp) #将生成的字母或者数字添加到变量里面
print('验证码:',checkcode1)# 将生成的验证码打印出来
checkcode1='' # 初始化验证码寄存器