如下所示:
'''
以下代码均为讲解,不能实际操作
'''
'''
博客园 Infi_chu
'''
'''
模块的优点:
1.高可维护性
2.可以大大减少编写的代码量
模块一共有三种:
1.Python标准库
2.第三方模块
3.应用程序自定义模块
'''
# import example # 调用example模块
# from example import example # 调用example模块中的一个example方法
'''
博客园 Infi_chu
'''
'''
包的特点:
1.有__init__.py文件
2.有很多模块组成
'''
# from test import example # test为包名,example模块名,一层嵌套
# from test.test1 import example # test1、test2均为包名,test1在test中,example为模块名
# from test.test1.func1 import example # func1是example模块中的一个func1方法
# import test # test为包名,此命令相当于执行了__ini