开发者

access variables of other functions

in python, how can i access the variables of one func开发者_运维技巧tion into another function, is it possible, i tried the global variable method but that doesn't work for me.

can someone help me, how to access the variables from one function to another function.


If you want to share data between functions then create a class and turn the functions into methods on the class.


Don't try to do this. Explicit is better than implicit - if your function needs access to certain variables, pass them in. If it needs to change a value in the calling function, return the new value.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜