[英]How to return data from one python file to another python file
我正在使用python文件。 我想调用另一个python代码。 有什么办法可以将数据从第二个python代码返回到调用python代码。 任何类似函数的值都会返回到调用函数。
我必须承认我没有看到问题:
test1.py
:
def myfunc():
return "spam!"
test2.py
:
import test1
print(test1.myfunc())
运行test2.py
时的输出:
spam!
将所有内容都放入类和函数中,并阅读许多有关导入模块的信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.