[英]Accessing a function variable from another file in python
必须运行功能检测以初始化其局部变量。
def detect():
detect.tmp = 1
def b():
print(detect.tmp)
detect()
b()
当然,您可以将一个python文件作为python模块导入并调用其功能,例如
from File1 import detect
print(detect.tmp)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.