模块化设计概念

模块:具有相似功能方法、类的组合
分为标准库和第三方模块
(1)标准库模块:python中自带模块,如math、os、turtle等
(2)第三方模块:用户自定义的模块,可上传至python官网供用户下载
模块设计的一些小知识点
(1)模块名.doc,用于查看模块介绍。如:
import math
print(math.doc)
运行结果为
This module provides access to the mathematical functions
defined by the C standard.意思是,从c标准定义。
(2)模块名.name,当模块被导入时,名字为导入的模块名,如
import math
此处 name 为math
如果是在math模块里面运行时,名字就为__main__
所以要测试写好的模块功能时,一边要判断,即
if name == main

猜你喜欢

转载自www.cnblogs.com/d-uan/p/12376670.html