标签:%s type time 海贼王 oba 交流 黑名单 成功 success
1.匿名函数
2.global
3.五角数
def getPentagonalNumber(n):
"""
功能:计算五角数
参数:n:循环的数值
"""
return n*(3*n-1)/2
count =0
for n in range(1,101):
if count <9:
print( "%.0f "%getPentagonalNumber(n),end="")
count += 1
else:
print( "%.0f"%getPentagonalNumber(n))
count = 0
4.分片提取
a = ‘<li><a href="http://www.4399dmw.com/haizeiwang/manhua/274923.html">海贼王826话 山治家族姐弟登场</a></li>‘
b = ‘<li><a href="http://www.4399dmw.com/haizeiwang/shipin/271774.html">海贼王燃烧之血超震撼游戏宣传片</a></li>‘
c = ‘<li><a href="http://www.4399dmw.com/haizeiwang/tupian/270215.html">海贼王第80卷SBS新鲜内容大放送!</a></li>‘
d = ‘<li><a href="http://www.4399dmw.com/haizeiwang/donghua/270363.html">海贼王730集 蔓雪莉的奇迹之泪</a></li>‘
e = ‘<li><a href="http://www.4399dmw.com/haizeiwang/juqing/262935.html">50条关于海贼王的小秘密 你都知道哪一些</a></li>‘
f = ‘<li><a href="http://www.4399dmw.com/haizeiwang/shipin/261621.html">尾田荣一郎现场彩页作画过程</a></li>‘
g = ‘<li><a href="http://www.4399dmw.com/haizeiwang/tupian/260698.html">海贼王2016年动画版年历</a></li>‘
h = ‘<li><a href="http://www.4399dmw.com/haizeiwang/tupian/260371.html">海贼王2016年官方月历欣赏</a></li>‘
i = ‘<li><a href="http://weibo.com/xiaduophoto">关注夏多老师微博 实时交流海贼王之道!</a></li>‘
print(a[13:65])
print(b[13:65])
print(c[13:65])
print(d[13:66])
print(e[13:65])
print(f[13:65])
print(g[13:65])
print(h[13:65])
print(i[13:41])
5.计算器
"""
def add(*jisuanqi):
print(jisuanqi)
a = (1,2,3,4,5,)
x = 0
for i in a:
x += i
print(x)
"""
def add(*args):
sum_ = 0
if len(args) ==0:
print(‘无效数字‘)
else:
for i in args:
sum_ += i
print(sum_)
add(1,2,3,4,5,6,7)
6.下水道
def add(*args):
print(args)
add(1,2,3,4,5,6,7)
7.注册
global_count = 0
def users():
u = input(‘username:‘)
Z = ‘qazwsxedcrfvtgbyhnujmikikolpQAZWSXEDCRFVTGBYHNUJMIKOLP‘
N =‘1234567890‘
T =‘.*&^%$#@!~‘
is_Z = False
is_N = False
is_T = True
for i in u:
if i in Z:
is_Z = True
if i in N:
is_N = True
if i in T:
is_N = False
if is_N and is_Z and is_T:
password()
else:
print(‘账号必须含有数字和字母且不能含有特殊字符‘)
def password():
password = input(‘password:‘)
if len(password) < 6:
print(‘密码必须大于6位‘)
else :
tel()
def tel():
import re
compile = re.compile(‘str‘)
compile.search
compile.findall
tel = input(‘请输入您的电话号码:‘)
if len(tel) != 11:
print(‘电话号码无效~‘)
else:
print(‘验证码已经发送‘)
verify_number()
#产生随机数
def verify_number():
global global_count
import random
import time
yanzhengma = random.randrange(1000,9999)
global_count += 1
start_time = time.time()
print(‘验证码为: %d‘ % yanzhengma)
input_ = int(input(‘输入你的验证码:‘))
end_time = time.time()
sub_time = end_time - start_time
if global_count > 2:
if sub_time >10:
print(‘您可萌是一个机器人嗷‘)
exit()
print(‘验证码超时,即将重发‘)
# time.sleep(3)
verify_number()
else:
# print(sub_time,type(sub_time))
if input_ == yanzhengma:
print(‘注册成功‘)
#success()
else:
print(‘验证码错误‘)
#return False
#验证码的有效期1分钟
#def success():
# print(‘恭喜您注册成功‘)
def Start():
users ()
Start()
8.倒计时
import time
for seconds in range(10,0,-1):
time.sleep(1)
print(‘\033[31m %d秒之后重新发送\r‘%seconds,end="",flush=True)
9.例子
def jo():
print(‘zz is a pig‘)
return 100
res = jo()
print(res)
10.买东西
def check(g):
商品库=[汽车,火车,飞机]
if g in 商品库:
return true
else:
return false
def xinxi():
姓名=input(‘请输入您的姓名:‘)
电话=input(‘请输入您的电话:‘)
地址=input(‘请输入您的地址:‘)
return true
def fahuo():
return true
‘‘‘
def check(g):
G = [‘汽车‘,‘火车‘,‘飞机‘]
if g in G:
Address()
else:
return False
def check_information(name,tel,addr):
is_ok = True
if name =="" or name ==" ":
is_ok = False
if len(tel) != 11:
is_ok = False
if addr not in [‘山东‘,‘北京‘]:
is_ok = False
return is_ok
def Address():
name = input(‘name:‘)
tel = input(‘tel:‘)
addr = input(‘addr:‘)
res = check_information(name,tel,addr)
if res:
note()
return False
def note():
print(‘明天发货‘)
def Start():
print(‘欢迎光临~‘)
g = input(‘商品:‘)
check(g)
Start()
11.循环
import time
i = 1
#phyton最大的软肋是精度丢失
while i !=0:
time.sleep(1)
print(i)
i -= 0.1
12.秒杀
def ms(a):
b = [‘vip-123‘]
if a in b:
print(‘你在我家花的钱真多‘)
else:
print(‘你被拉入黑名单了你知道吗‘)
标签:%s type time 海贼王 oba 交流 黑名单 成功 success
原文地址:https://www.cnblogs.com/bishuyu/p/11297848.html