OS Module
This module contains common operating system functions.
This module is especially important if you want your program to be platform-agnostic. An example is the use of OS.SEP to replace the operating system-specific path delimiters.
Os.system () |
Execute the linux command >> os.system( ‘ls -l‘ ) You can also use the Subprocess module
>> subprocess.call( ‘ls -l‘ . split ())
|
OS.GETCWD () |
Get Current working directory |
Os.getenv () and os.putenv () |
Reading and setting environment variables |
Os.listdir () |
Returns all file and directory names under the specified directory |
Os.remove () |
deleting files |
Os.system () |
Run the shell command |
Os.path.split () |
Returns the directory name and file name of a path >>> os.path.split ('/home/swaroop/byte/code/poem.txt ') ('/home/swaroop/byte/code ', ' poem.txt ') |
Os.path.isfile () and Os.path.isdir () |
Individually verify that the given path is a file or a directory |
Os.path.exists () |
Verify that the given path is really present |
Os.linesep |
Gives the line terminator used by the current platform. For example, Windows uses ' \ r \ n ', Linux uses ' \ n ' and Mac uses ' \ R ' |
Os.name |
Indicates the platform you are using. For example, for Windows, it's ' NT ', and for Linux/unix users, it's ' POSIX '. |
SYS module
sys
The module contains the functions that the system corresponds to.
1. sys.argv
Contains command-line arguments, sys.argv[0]是
currently running program names
Output:
2. Sys.exit
Quit a program that is running. As always, you can check out Help (sys.exit) for more details.
3. Sys.stdin, Sys.stdout and Sys.stderr
They correspond to your program's standard input, standard output, and standard error stream, respectively.
Data
Tools for working with Lists describes collections. Deque,bisect and HEAPQ, are very useful data structures
Other
The introduction here is quite limited and can be consulted in detail in the Python standard library and the Python Language Reference
- Brief Tour of the standard Library
- 10.1. Operating System Interface (os,shutil)
- 10.2. File wildcards (glob)
- 10.3. Command line Arguments (sys,getopt,argparse)
- 10.4. Error Output Redirection and program termination (sys)
- 10.5. String Pattern Matching (re)
- 10.6. Mathematics (math,random)
- 10.7. Internet Access (urllib2,smtplib,poplib)
- 10.8. Dates and Times (datetime)
- 10.9. Data Compression (zlib, gzip, bz2, zipfile and tarfile)
- 10.10. Performance measurement (Timeit, profile and pstats)
- 10.11. Quality Control (doctest,unittest)
- 10.12. Batteries Included
- Data Interchange CSV, xml.dom, xml.sax
- Internationalization gettext, locale, and the codecs
- Remote procedure Calls xmlrpclib,simplexmlrpcserver
- Managing email Messages Email
- Brief Tour of the Library–part II
- 11.1. Output formatting (repr,pprint,textwrap,locale)
- 11.2. Templating (string. Template)
- 11.3. Working with Binary Data Record Layouts (struct, read zip file directly)
- 11.4. multi-threading (threading)
- 11.5. Logging (Logging)
- 11.6. Weak References (weakref)
- 11.7. Tools for working with Lists (array,collections. Deque (),HEAPQ)
- 11.8. Decimal floating point arithmetic (decimal. Decimal)
http://www.guokr.com/blog/480782/
Http://docs.python.org/2/tutorial/stdlib.html
Http://docs.python.org/2/tutorial/stdlib2.html
Http://docs.python.org/2/contents.html
More Python Resources:
- Http://www.python.org:The major Python Web site. It contains code, documentation, and pointers to python-related pages around the Web. This WEB site was mirrored in various places around the world, such as Europe, Japan, and Australia; A mirror may is faster than the main site, depending on your geographical location.
- Http://docs.python.org:Fast access to Python ' s documentation.
- Http://pypi.python.org:The Python Package index, previously also nicknamed the Cheese Shop, was an Index of user-created P Ython modules that is available for download. Once you to begin releasing code, you can register it with this so-others can find it.
- http://aspn.activestate.com/ASPN/Python/Cookbook/: The Python Cookbook is a sizable collection of code examples, larger MO Dules, and useful scripts. Particularly notable contributions is collected in a book also titled Python Cookbook (O ' Reilly & Associates, ISBN 0- 596-00797-3.)
- From:http://www.cnblogs.com/wei-li/p/3438713.html
Concise python Tutorial--c++ Programmer's Perspective (eight): standard library