2.python Syntax Basics-Modules

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.