带参数的装饰器
def wrapper_out(n):
# def wrapper(f):
# def inner(*args,**kwargs):
# # if n == 'qq':
# # username = input('请输入用户名:').strip()
# # password = input('请输入密码:').strip()
# # with open('qq',encoding='utf-8') as f1:
# # for line in f1:
# # user,pwd = line.strip().split('|')
# # if username == user and password == pwd:
# # print('登陆成功')
# # ret = f(*args,**kwargs)
# # return ret
# # return False
# # elif n == 'tiktok':
# # username = input('请输入用户名:').strip()
# # password = input('请输入密码:').strip()
# # with open('tiktok', encoding='utf-8') as f1:
# # for line in f1:
# # user, pwd = line.strip().split('|')
# # if username == user and password == pwd:
# # print('登陆成功')
# # ret = f(*args, **kwargs)
# # return ret
# # return False
# username = input('请输入用户名:').strip()
# password = input('请输入密码:').strip()
# with open(n,encoding='utf-8') as f1:
# for line in f1:
# user,pwd = line.strip().split('|')
# if username == user and password == pwd:
# print('登陆成功')
# ret = f(*args,**kwargs)
# return ret
# return False
# return inner
# return wrapper
# """
# # @wrapper_out('qq')
# # def qq():
# # print('成功访问qq')
# # qq()
# # 看到带参数的装饰器分两步执行:
# '''
# @wrapper_out('腾讯')
# 1. 执行wrapper_out('腾讯') 这个函数,把相应的参数'腾讯' 传给 n,并且得到返回值 wrapper函数名。
# 2. 将@与wrapper结合,得到我们之前熟悉的标准版的装饰器按照装饰器的执行流程执行。
# '''
# """
# @wrapper_out('qq')
# def qq():
# print('成功访问qq')
# @wrapper_out('tiktok')
# def tiktok():
# print('成功访问抖音')
# qq()
# tiktok()
多个装饰器装饰一个函数

递归函数
递归函数:函数或者其他代码都可以解决递归解决的问题,但是递归在某些时候能出奇制胜的效果,人理解函数,神理解递归。
自己用自己。
