所以我有2个文档:
document_a.py 和 document_b.py
document_a.py 具有以下代码:
from document_b import hello
age = 31
hello('Eric')
document_b.py 具有以下代码:
def hello(name):
print('Hello',name)
print('age:',age)
如何获取 document_a.py 上的 age 变量,以传递给 document_b上的 def hello(名称):。 py ?
答案 0 :(得分:0)
您以无法进行的方式进行设置,因此必须进行某些更改。
您可以更改功能:
scala
并使用timestamp
对其进行调用。
另一种选择是在def hello(name, age):
print('Hello',name)
print('age:',age)
中定义一个全球年龄:
hello('Eric', age)
然后document_b
应该看起来像这样:
age = 0
def hello(name):
print('Hello',name)
print('age:',age)