才疏学浅,只知道两种方式:

1. 通过__builtin__实现:

builtin1.py

import __builtin__
__builtin__.some_global_var_among_modules='blablabla'

builtin2.py

import builtin1
print some_global_var_among_modules

  

 

2. 通过类的静态属性实现

A.py

class A:
    b=1

B.py

import A
print A.b

  

相关文章:

  • 2021-09-16
  • 2022-12-23
  • 2021-11-08
  • 2022-12-23
  • 2022-12-23
  • 2021-09-16
  • 2021-01-19
  • 2022-12-23
猜你喜欢
  • 2021-10-09
  • 2022-01-04
  • 2021-08-23
  • 2022-12-23
  • 2021-09-16
  • 2021-09-16
  • 2021-09-16
相关资源
相似解决方案