python的组织架构:包>>模块>>类>>函数、变量
一、import
导入:
#在test.demo1中
a = 8
#在demo6中导入test.demo1的a
import test.demo1 as f1
print(f1.a)
>>>
8
若出现AttributeError:报错,可能是被导入的文件没有先执行,解决:run一下被导入的文件
python的组织架构:包>>模块>>类>>函数、变量
导入:
#在test.demo1中
a = 8
#在demo6中导入test.demo1的a
import test.demo1 as f1
print(f1.a)
>>>
8
若出现AttributeError:报错,可能是被导入的文件没有先执行,解决:run一下被导入的文件