摘要: 装饰器 = 高阶函数 + 闭包 1.什么是闭包; # 闭包:就是不执行,等待调用状态 def fun(): print("执行函数") f = fun print(type(f),f) # <class 'function'> <function fun at 0x000002139B203438> 阅读全文
posted @ 2021-06-30 16:19 3ξ 阅读(30) 评论(0) 推荐(0) 编辑
摘要: # print(globals())#全局变量 # print(locals())#局部变量 arr = dir(__builtins__)#这个可以看内置的方法哦 for i in range(len(arr)): print(f"{i} {arr[i]}") 下面的是具体有哪些内置方法:等我有空 阅读全文
posted @ 2021-06-30 15:52 3ξ 阅读(44) 评论(0) 推荐(0) 编辑
摘要: ''' filter :过滤掉一些东西 map :无特殊 reduce:一次性执行两个参数:让数组【1,2,3】变成123 ''' # print(list(filter(lambda x:True if x>3 else False,range(10)))) # print(list(map(la 阅读全文
posted @ 2021-06-30 15:35 3ξ 阅读(35) 评论(0) 推荐(0) 编辑
摘要: 1.字符串 》datetime dd = '2019-03-17 11:00:00' dd = datetime.datetime.strptime(dd, "%Y-%m-%d %H:%M:%S") 2.datetime >字符串 dc = dd.strftime("%Y-%m-%d %H:%M:% 阅读全文
posted @ 2021-06-30 15:03 3ξ 阅读(88) 评论(0) 推荐(0) 编辑
摘要: import random # 随机数 print(random.randrange(1,2)) # 返回值从列表里拿一个字符 print(random.choice([1,2,3])) # 返回值,从列表里拿N个数据,放在列表里 print(random.sample([1,2,3],2)) # 阅读全文
posted @ 2021-06-30 14:52 3ξ 阅读(47) 评论(0) 推荐(0) 编辑
摘要: 得到当前工作目录,即当前Python脚本工作的目录路径: os.getcwd() 返回指定目录下的所有文件和目录名:os.listdir() 函数用来删除一个文件:os.remove() 删除多个目录:os.removedirs(r“c:\python”) 检验给出的路径是否是一个文件:os.pat 阅读全文
posted @ 2021-06-30 14:34 3ξ 阅读(43) 评论(0) 推荐(0) 编辑
摘要: with app.app_context(): obj = db.session.query(A).filter().all() 阅读全文
posted @ 2021-06-30 09:40 3ξ 阅读(44) 评论(0) 推荐(0) 编辑