有什么方法可以从另一个模块中的另一个函数访问局部变量

时间:2020-10-11 12:59:55

标签: python-3.x variables

我创建了两个模块1)主2)备用 我想访问局部变量-name,该变量存在于主模块功能的功能内的备用模块中

主模块:

from spare import *
def main():
 spare() #executing function here so variable can generate
 print('Hello',name) #which is in spare module's function

备用模块:

def spare():
  name=input("Enter your name")

0 个答案:

没有答案