前提是d8和d9都是demo包下的
d8.py内容:
print('~~~~~~~~~~~~~~~~~~~~~d8~~~~~~~~~~~~~~~~~~~~')
print('name: ' + __name__)
print('package: ' + (__package__ or '该模块不属于任何包'))
d9.py内容:
import d8
print('~~~~~~~~~~~~~~~d9~~~~~~~~~~~~~~~')
print('name: ' + __name__)
print('package: ' + (__package__ or '该模块不属于任何包'))
运行python3 d9.py
显示:
~~~~~~~~~~~~~~~~~~~~~d8~~~~~~~~~~~~~~~~~~~~
name: d8
package: 该模块不属于任何包
~~~~~~~~~~~~~~~d9~~~~~~~~~~~~~~~
name: __main__
package: 该模块不属于任何包
是不是就是说同一个级别的模块的导入package都是提示没有包的