一、环境配置
1.Python3的环境安装
2.pycharm的安装
二、直接上代码
#coding:utf-8
importrandom
defsuijihaoma():#产生随机手机号码
list=['(移动)134','(移动)135','(移动)136','(移动)137','(移动)138','(移动)139','(移动)150',
'(移动)151','(移动)152','(移动)157','(移动)158','(移动)159','(移动)187','(TD专用)188',
'(联通)130','(联通)131','(联通)132','(联通)155','(联通)156','(联通)185','(联通)186',
'(电信)133','(电信)153','(电信)180','(电信)189',]
shouji = random.choice(list)
haoma='0123456789'
haom=''
haoma1=[]
for i in range(8):
haoma1.append(random.choice(haoma))
haom =''.join(haoma1)
print(shouji + haom)
suijihaoma()
li=[ ] #生成随机验证码,将每次产生的单个验证码保存
i =1
whilei <=4: #产生4个随机数
temp = random.randint(1,3) #决定验证码每个位置应该是大写字母还是小写字母还是数字
if temp == 1:
num = random.randint(65,90)
char=chr(num)#转换为大写
li.append(char)
elif temp == 2:
num = random.randint(97,122)
char =chr(num)#转换为小写
li.append(char)
else :
num = random.randint(0,9)
char =chr(num)
li.append(char)
i +=1
s =''.join(li)
print(s)
三、运行结果