当前位置:首页 > Python教程 > python技巧

python 模块导入全局变量

在哪种情况下需要从模块导入全局变量

  • 项目里多个脚本均更改「某一个全局变量」时
  • 全量变量需要实现可配置时

从模块导入全局变量的方法

        from test_prokject import global_variables

def get_global_variables():
    print(global_variables.deco_trigger)
 
# 其中 global_variables 为文件名,global_variables 文件内容为:deco_trigger = None
    

原文:https://www.cnblogs.com/ronky/p/9831521.html


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!

相关教程推荐

其他课程推荐