from settiing import *
from boy import *
def start():
value = web() // Import data from the web (value=[4,5,6])
gosetting(value)
goBoy()
a = 1
b = 2
c = 3
def goSetting(value):
global a
global b
global c
if value:
a = value[0]
b = value[1]
c = value[2]
else:
pass
from setting import *
def goBoy():
print("a: ", a)
Let me ask you a question.
The goBoy()
value of the main.py
file is
I want to get the a:4
value, but a:1
comes out.
In the end, I want to use the a
, a
, b
, and c
values in other modules like global variables, but this doesn't work!
How can I use data that I received on the web initially as a global variable?
python global-variable
If it were me, setting.I'll make a class called setting by modifying the py a little bit.
class Setting:
def __init__(self, value):
if len(value) == 3:
self.a = value[0]
self.b = value[1]
self.c = value[2]
def goBoy():
print("a: ", self.a)a)
def start():
value = web()
s = Setting(value)
s.goBoy()
© 2024 OneMinuteCode. All rights reserved.