Python 02-Modules

Source: Internet
Author: User

The encapsulated function is the module (library).

There are two types of libraries:

Standard library, do not need to install the library can be imported directly;

Third-party libraries that must be installed.

Primary Knowledge Standard Library

Sys

Import SYS Print (Sys.path)

To adjust the function through the "library name, function name" implementation

Third-Party inventory path: D:\Program files\python\python3.5\lib\site-packages

Standard inventory drop path: D:\Program files\python\python3.5\lib

Take parameters

Import SYS Print (sys.argv[2]) F:\PycharmProjects\lesson\week2>python sys_mod.py 1 2 32

View files in the current directory

Cmd_res=os.system ("dir")# executes the command without saving the result Cmd_res=os.popen (" dir "). Read ()#read () Use this method to fetch the result print(cmd_res) os.mkdir ("new_ Dir")# Add a new directory

Calling third-party modules

Import Module Name

This module can be placed in the \python3.5\lib\site-packages, or add the path of the third-party module

Python 02-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.