'''
def filterchar(string):
"功能:过滤危险字"
import re
pattern=r'(黑客)|(抓包)|(监听)'
sub=re.sub(pattern,"fuck",string) #替换
print(sub)
about="我是黑客,喜欢监听和抓包."
filterchar(about)
def function_tips():
"每天输出一条励志文字"
import datetime
mot=["no zuo no die","to be or not to be","everything is great","believe yourself","hhhh","simalu","trigger"]
day=datetime.datetime.now().weekday()
print(mot[day])
function_tips()
def fun1(person,weight,high):
print(person+"的身高为:"+str(high)+" 体重为:"+str(weight))
fun1("wangwu",1,1)
person="lisi"
high=1.85
weight=140
fun1(person,high,weight)
fun1(weight=140,person="ww",high=1.7) #关键字参数,其位置不需要按照行参的顺序
def fun1(person,weight,high=160):
print(person + "的身高为:" + str(high) + " 体重为:" + str(weight))
fun1("www",1.9) #设置默认形参,且要在最后
print(fun1.__defaults__) #输出默认姓参
fun1("ll",111,222)
def fun2(*coffee): #可变参数
for item in coffee:
print(item)
fun2("wwww",111,"a")
def fun_upgrade(*person):
for list_person in person:
for item in list_person:
person=item[0]
weight=item[1]
high=item[2]
print(person + "的身高为:" + str(high) + " 体重为:" + str(weight))
w=[("www",140,1.9),("yyyy",120,1.8)]
w1=[("zzz",140,1.75)]
fun_upgrade(w,w1)
def fun3(**sign):
for key,value in sign.items(): #字典
print("["+key+']的星座为:'+value)
s1={"www":"shuangyu","22":"shuiping"}
fun3(**s1)
def fun_checkout(money):
money_old=sum(money)
money_new=money_old
if money_old>500and money_old<1000:
money_new='{:.2f}'.format(money_old*0.9)
elif money_old>=1000:
money_new='{:.2f}'.format(money_old*0.8)
return money_old,money_new
list_money=[]
while True:
inmoney=float(input("请输入金额,输入0表示完毕"))
if int(inmoney)==0:
break
else:
list_money.append(inmoney)
money=fun_checkout(list_money)
print("合计金额为:"+str(money[0])+"应付金额为:"+str(money[1]))
'''
import math
r=10
result=lambda r:math.pi*r*r #匿名函数
print(result(r))
book=[("book1",22,120),("book2",22,140),("book3",10,100)]
book.sort(key=lambda x:(x[1],x[2]/x[1]))
print(book)