python之模块调用

 

1.以 atm_run 为入口,在atm中的main模块调用config中的settings

from config import settings

 

2.以atm_run为入口,在main中调用logger中的方法log

from .logger import log

 

3.

python之模块调用

在同一模块目录下,modules 想要调用my_modules模块

from . import my_module

 

4.跨模块导入

 sys
Base_Dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))  # 找到想要调用模块所在位置的路径                                                  
sys.path.append(Json_file)  #添加到python的搜索模块的路径集

 

 

相关文章:

  • 2021-11-07
  • 2021-06-26
  • 2022-12-23
  • 2022-12-23
  • 2021-07-08
  • 2022-12-23
  • 2021-08-24
猜你喜欢
  • 2021-08-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-10
  • 2021-11-09
相关资源
相似解决方案