定义一个MathLib.py文件
import math
def RectArea(width,height):area=width*heightreturn areadef CircleArea(radius):area=math.pi*radius*radiusreturn areaprint("MathLib Module Name:",__name__)
if __name__=="__main__":print(RectArea(2,3))print(CircleArea(2))
再定义一个Test.py文件
import MathLib
w=12
h=20
r=2
print("Test Module Name:",__name__)
print(MathLib.RectArea(w,h))
print(MathLib.CircleArea(r))