Python 3.x PythonL如何输入变量,然后使用它在另一个文件中执行,然后打印到第一个文件?

Python 3.x PythonL如何输入变量,然后使用它在另一个文件中执行,然后打印到第一个文件?,python-3.x,Python 3.x,我的第一个文件包含以下代码: def main(self): age = input("Enter your age: ") ins = Aged() ins.ageplus() main() *我需要在main()中调用main()时打印它 您需要将年龄作为参数传递给ageplus函数 其次,假设您的第二个文件名为age.py 在第一个文件的顶部添加from age import age My second file: class Aged(): def a

我的第一个文件包含以下代码:

def main(self):
    age = input("Enter your age: ")
    ins = Aged()
    ins.ageplus()

main()
*我需要在main()中调用main()时打印它


您需要将年龄作为参数传递给
ageplus
函数

其次,假设您的第二个文件名为age.py

在第一个文件的顶部添加
from age import age

My second file:
class Aged():
    def ageplus():
    print("Your new age is:", age)