How to Access Function variables in Another Function

后端 未结 5 1783
梦如初夏
梦如初夏 2020-12-10 09:29

I have a small issue while calling multiple variables in python one function to another. Like I have to access the variable of xxx() variables in yyy(). Help me to do this.?

5条回答
  •  不知归路
    2020-12-10 10:17

    Use the global keyword, like the following example:

    global a=0
    global b=0
    global c=0
    
    def xxx():
        a=10
        b=15
        c=20
        return a,b
    
    def yyy():
        print a
        print b 
        xxx()
    

提交回复
热议问题