2023年3月22日

自定义模块

摘要: 导入模块后,python默认会取几个位置寻找 -当前py文件(脚本)所在的目录 -内置模块中寻找(安装python的目录) \Programs\Python\Python310\python310.zip \Programs\Python\Python310\DLLs \Programs\Pytho 阅读全文

posted @ 2023-03-22 21:08 笨鸟晚飞le 阅读(16) 评论(0) 推荐(0) 编辑

高阶函数

摘要: 闭包: def func(n1): var = 123 def inner(): print(var,n1) return inner​res = func(6) #<function func.<locals>.inner at 0x000001FBE04AEC20>res() #123 6 闭包 阅读全文

posted @ 2023-03-22 14:43 笨鸟晚飞le 阅读(15) 评论(0) 推荐(0) 编辑

python常用内置函数

摘要: 1.默认参数 函数中设置的默认参数出现可变类型 需要注意 如:list/dict def func(a2=[]): a2.append(2) print(a2)​func()func([1])func()结果:[2][1,2][2, 2]错误分析:执行函数未穿参数,每次执行默认创建一个空列表赋值给a 阅读全文

posted @ 2023-03-22 09:32 笨鸟晚飞le 阅读(13) 评论(0) 推荐(0) 编辑

导航