【Python】包、模块、函数与变量作用域


一个py文件(模块)可以写多个类
【Python】包、模块、函数与变量作用域

必须要有__init__.py
【Python】包、模块、函数与变量作用域包名
【Python】包、模块、函数与变量作用域

init

init
【Python】包、模块、函数与变量作用域导入,会自动运行init
【Python】包、模块、函数与变量作用域
导入包下的变量也会自动运行init
【Python】包、模块、函数与变量作用域
初始化限制导入模块 c7 c8 init
【Python】包、模块、函数与变量作用域
【Python】包、模块、函数与变量作用域
【Python】包、模块、函数与变量作用域
【Python】包、模块、函数与变量作用域批量导入系统库
【Python】包、模块、函数与变量作用域【Python】包、模块、函数与变量作用域

注意包和模块的导入注意

【Python】包、模块、函数与变量作用域

引用

c7
【Python】包、模块、函数与变量作用域c8
【Python】包、模块、函数与变量作用域c7如果在子包
【Python】包、模块、函数与变量作用域简化
【Python】包、模块、函数与变量作用域
导入具体变量
【Python】包、模块、函数与变量作用域
简化

【Python】包、模块、函数与变量作用域

批量导入
【Python】包、模块、函数与变量作用域
【Python】包、模块、函数与变量作用域
导入*代表的指定文件,只导入了ac
【Python】包、模块、函数与变量作用域
【Python】包、模块、函数与变量作用域导入指定数据
【Python】包、模块、函数与变量作用域一行80字符建议,换行\ 或者 ()
【Python】包、模块、函数与变量作用域【Python】包、模块、函数与变量作用域

自动生成

【Python】包、模块、函数与变量作用域设置缓存文件夹不可见
【Python】包、模块、函数与变量作用域实际文件还是存在
【Python】包、模块、函数与变量作用域