Python QuickStart (5)

Source: Internet
Author: User
Tags glob

OS module: Operating system interface

You should use the Import OS style instead of the From OS import *. This ensures that Os.open (), which varies with the operating system, does not overwrite the built-in function open () is useful for using the Dir () and help () functions built into large modules such as the OS.

For daily file and directory management tasks, the Shutil module provides an easy-to-use, high-level interface.

Glob module: Generate a list of files from the directory wildcard search

1 Import Glob,os 2 os.chdir ('Desktop')3 glob.glob ('*.desktop  ')4 ans: ['xxx.desktop']

Command-line arguments: command-line arguments are stored as a list of argv variables in the SYS module.

1 Import SYS 2 Print sys.argv

SYS also has the Stdin,stdout,stderr property, which can be used to display warnings and error messages even when STDOUT is redirected.

Sys.stderr.write (' warning .... ')

Most scripts are directed to terminate using Sys.exit ()

Re module: string matching

For a simple operation, the string method is best used:

' Tea for too '. Replace ('too','both ')

Smtplib module: Sending an email

URLLIB2 module: Access to the Internet

DateTime module: Date and time processing

REPR module: Provides a customized version of the REPR () function for large or deep nested container abbreviation displays

Pprint module: Provides an interpreter-readable way to deeply control the printing of built-in and user-defined objects.

TextWrap module: Modules format text paragraphs to fit a set screen width

Locale module:

Template module:

Python QuickStart (5)

Related Article

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.