2. Module code example (based on code)
--------------------------------------------------------------------------------------------------------------- -------------------
package.py main file:src\py\package.py # Coding:utf8" "2. The use of the package is also known as: module, module, header file" "Import time #第一种导入 all methods are available #from time import * #第二种导入time#from Selenium import webdriver #第三种导入import package2 #导入自己写的包 from py3 import package4 from py2 import package3 #获得当前时间并打印出来print '----------Current time: ', Time.ctime () #调用导入的package2中的方法print '----------calling method results in Package2: ', package2.packagefun2 (1, 3) #调用不在一个包内的文件print '----------call method results in Package3 under Py2 package: ', Package3.packagefun3 (1, 5) print '----------call method results in Package4 under Py3 package: ', Package4.packagefun4 (5, 5)
--------------------------------------------------------------------------------------------------------------- -------------------package2.py File:src\py\package2.py # Coding:utf8" the method provided to the package"def packageFun2(x, y): C=x+y return c---------------------------------------------------------------------------------------
package3.py file: src\py\py2\package3.py
# Coding:utf8" the method provided to the package"def packageFun3(x, y): C=x+y return c --------------------------------------------------------------------------------------- package4.py file: src\py3\package4.py
# Coding:utf8" the method provided to the package"def packageFun4(x, y): C=x+y return c
---------------------------------------------------------------------------------------
From for notes (Wiz)
2.python Syntax Basics-Modules