- Forums
- Help
- Python global variables encountered a problem and asked God for an answer.
Python global variables encountered a problem and asked God for an answer.
Author:
tony233, Created: 2021-09-08 14:20:01, Updated: 2021-09-08 15:09:44
I found a problem, why I return a dictionary global variable, and when I call it again, the variable is overwritten, the code is below, and the three lines of code # are theoretically supposed to be printed as 1, 2, 3, but actually printed as 3, 3, 3. I don't understand.
def fun ((a):
dict_zz [supplemented with salt] = a
return dict_zz is used
def main (:
Params ((()
I'm not sure what you mean.
dict_zz_1h = fun ((2)
dict_zz_4h = fun ((3)
I'm going to go to the bathroom.
I'm going to print it.
I'm not sure.
def params():
global dict_zz
dict_zz = {}
main()
Why did I print it like this?
What's that?
What's that?
What's that?
More
- Ask the okex v5 api to get the 1440 roots of the K-line function, which one of the big boys has it out.
- How do you write in Python to buy at the market price when one of the latest three-minute tabs is about to close?
- GetRecords problem with getting the number of k-strings
- Handwritten TV version of KDJ indicator, which is completely incompatible with TV and FMZ
- I'm going to ask you a question, in retrospect: hours and minutes?
- The programmer himself found a trader to work with.
- In python quantification transactions, if the current signal is too much, but you already have a blank list in your hand, how do you write it?
- How do you start a Bitcoin websocket account and transaction information in Python?
- Difference between Exchange API and FMZ API
- Is there any statistical graph code for the retest?
- Why does fmz say in pycharm that there are no get_bars?
- Is the platform's salary a solution to the problem, don't delete the post, delete the account, discuss
- Do inventors intend to support the DEX exchange?
- I have a problem and I ask God for an answer.
- Can you write the pine code on the TV, big brother, and help me turn the indicator into a warning?
- When the hard drive starts, there is a listing behavior that reports this error.
- What is the role of the K-line cycle in the real disk and the retest?
- Please tell me how to write the KDJ and MACD indicator strategies for digital currencies.
- About the Contract Calculator
- Ask if the platform is able to get the number of people trading on the exchange 24 hours a day.
The grassYou're learning the basics of Python.
tony233You just say that the dictionary is shorthand and I get it... my mom, who has been learning Python for so long, doesn't understand this.
The grass def fun(a):
dict_zz['one'] = a
return dict_zz
def main():
params()
dict_zz_15min = fun(1)
print(dict_zz_15min)
dict_zz_1h = fun(2)
print(dict_zz_1h)
dict_zz_4h = fun(3)
print(dict_zz_4h) #
def params():
global dict_zz
dict_zz = {}
main()
tony233You're a bit of a jerk, what's a python base?
tony233It's not a key problem, I'm just switching global variables to local variables, so it's okay, like, key doesn't even cover that?
def fun ((a):
dict_zz = {}
dict_zz ['one'] = a
return dict_zz is used
def main (:
I'm going to have fun.
dict_zz_1h = fun ((2)
dict_zz_4h = fun ((3)
I'm going to try to get a copy of this.
print ((dict_zz_1h))
print ((dict_zz_4h))
main ((()
tony233It's not a key problem, I'm just switching my global variables to local ones.