Python Study Notes: Common Modules
Python Common Libraries (Official website: http://docs.python.org/release/2.5.2/lib/lib.html)
import os// Functions related to the operating system: directories, files, system command execution (system),fork,execfamily, etc.import sys// System-specific parameters and common processing functionsimport subprocess// Replaces olderosexecution functions (like pipes)import multiprocessing// Inter-process communication: processes, message queues, shared memoryimport threading// Inter-thread communication: threads, thread queues, thread locksimport thread// Another library/method for inter-thread creation and communicationimport Queue// Message queuesimport time// Time operations and functionsimport signal// Signal handling functions (e.g.,signal)import socket// Socket communication functions:socket,accept,gethostname,connect,listen, etc.import urllibimport praselibimport smtplibimport xmllibimport telnetlib...
Python Compilation File Formats
.pyc
Python compiled binary cross-platform files. Note that lower versions cannot load.pycfiles generated by higher versions.- Usage in code:
1
2import py_compile
py_compile.compile("dirpath") - Command line:
1
python -m py_compile *.py
- Note: There is also a
compilealllibrary available.
- Usage in code:
.pyo
Python optimized compiled binary cross-platform files. Similarly, lower versions cannot load files generated by higher versions.- Command line:
1
python -O -m py_compile *.py
- Command line:
.pyd
Python dynamic link libraries (DLLs).