初始化说 __init__.py
背景理论
1. __init__.py用来标识所在目录是一个python的模块包(module package)
request
|__init__.py --> print('I from the __init__.py of request.')
|api.py --> def view(): pass>>> import request
I from the __init__.py of request.2. __init__.py用来控制模块的导入,对外提供功能
# __init__.py 导入其他功能时,注意工作目录
from request.api import view
print('I from the __init__.py of request.')源码分析
项目结构

Last updated