python包的引用

class05为python包,classes为python中的模块,Dog和ChinaDog为classes中的方法

from class05 import classes

可以使用classes模块中的变量

from class05.classes import Dog,ChinaDog

只能使用Dog和ChinaDog方法

模糊导入* 由__all__来定义,__init__.py的另一个作用就是定义package中的__all__,用来模糊导入,只针对模块,比如在__init__.py中输入__all__=['m1','m2']

from class05 import *时能使用m1和m2,m1为模块(如classes)

原文地址:https://www.cnblogs.com/wendy-0901/p/12365870.html