3-Using and importing modules

Source: Internet
Author: User

Import Module Import Module Name                                                          Import OS Os.system ( ' date ')                       import os as Win8                module name is too long and can be alias     From Module Name Import Call method                            From OS import system                 system (' Date ')
                 From OS import *             * All methods under Call module

Import a custom module . py file
folder
     folder must There are __init__.py files, otherwise folder and the following Py module cannot be imported                 
                    System Module Import OSImport Module Os.system (")Calling module
Os.popen ("). Read () Call module command execution result
Import Commands commands.getstatusoutput (")     or invoke the execution result with the commands module
Import SYS SYS.ARGV        parameter values, all parameters are taken Sys.argv[2]     take position of 2 parameters


Custom ModulesCreate a new module moudle.py call module and print a word
Invokes the module and executes
Once executed, a PYC file is automatically generated.


Path , the module under this path can be imported directly using the
Sys
Sys.path







From for notes (Wiz)

3-Using and importing 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.