python学习ing
##注册验证用户
def users():
users_ = input('users: ')
k1 = 'qwertyuiopasdfghjklzxcvbnm'
k2 = '1234567890'
k3 = '!@#$%^&*()_+'
is_k1 = False
is_k2 = False
is_k3 = True #初始化变量
for i in users_:
if i in k1:
is_k1 = True
if i in k2:
is_k2 = True
if i in k3:
is_k3 = False
if is_k1 and is_k2 and is_k3:
password()
else:
print('不能有特殊字符')
def password():
password = input('输入密码: ')
if len(password)<6:
print('密码必须大于六位')
else:
phone()
def phone():
phone = input('请输入电话: ')
if len(phone) != 11:
print('电话号码无效')
else:
print('验证码已发送')
verfily_number()
def verfily_number():
import random
import time
num=random.randrange(1000,9999)
Start_time = time.time()
print('验证码是: %d '%num)
num_ = int(input('请输入验证码'))
end_time = time.time()
sub_time = end_time - Start_time
if sub_time > 10:
print('验证码失效,重发...')
time.sleep(2)
verfily_number()
else:
if num == num_:
print('验证成功')
else:
print('验证错误')
def Start():
users()
Start()