http://blog.csdn.net/niying/article/details/637084 1:在头文件是声明变量,然后在使用的文件中用exten标识. ".h": int ntemp; ".cpp": exten int ntemp; 2:定义一个全局变量类,使用时包含头文件即可: "GlobalVar.h" Class CGlobalVar{ CGlobalVr(); ~CGlobal
如果是在同一个 module中(也就是同一个py 文件里),直接用就可以如果在不同的module里,例如a.py里有 class A:b.py 里有 class B:如果你要在class B里用class A 需要在 b.py的开头写上 from a import A #mymodel.py import matplotlib.pyplot as pltclass test(object): num = [] def __init__(self, _list): super(test, self