Common built-in libraries for Python

Source: Internet
Author: User
Tags glob

Standard library:

Import OS

OS.GETCWD ()//return current working path

Os.chdir ('/server/accesslogs ') # Change current working directory

The Dir () function is one of the most common and useful functions of python. It returns a list of all property names that contain the object to query

Import Shutil

Shutil.copyfile (' data.db ', ' archive.db ')//Copy files

Shutil.move ('/build/executables ', ' installdir ')//delete files

Glob File path Lookup:

Glob.glob

Returns a list of all matching file paths. It has only one parameter pathname, which defines the file path matching rule, which can be either an absolute or a relative path. Here's an example of using Glob.glob:

Import Glob

Glob.glob (' e:\*.py ')

Re

Regular expression Matching

Math

Random

Urlib2

Common built-in libraries for Python

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.