[英]i am trying to pass one variable from one python file to another python file
sample_box.py
gr=0
class SampBoxLayout(BoxLayout):
def input_rpm(self, instance, value):
if value is True:
global gr
gr=22
pyth.py
from sample_box import gr
while(True):
if(gr== '22'):
尝试创建一个常量而不是普通变量:
GR = 0
然后导入它:
import sample_box
要获取常量,请使用以下语法:
sample_box.GR
将此添加到您的代码中以防止导入语句运行 sample_box.py:
GR = 0
if __name__ == "__main__":
# all your code that you don't want to run here
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.