First, understand the Python module :
-- What is a function:
A function is a program that implements one or more functions
A module is a program block that implements a class of functions, a script file that contains functions and other statements, with a suffix of ". Py"
By default, the module is stored in c:/python27/lib
-- How to import the module: using import
We want to be able to show the value of pi directly, but no.
Now, import the corresponding module name using import, we can get the value of pi
-- Understanding the sys module
SYS module: modules related to system functions
Sys.version--View version information
Sys.executable--The file name that the parser can perform
Sys.getwindowsversion ()--Version information
Second,"*. PYc file": Apython parser-generated binary file after the module is compiled
three,F orm ... import ...
1. Import Module Name: Imports the corresponding module (see one )
2.from. Import function name (function, attribute, etc.): one of the functions that the import module corresponds to
3.from. Import *: Import all functions of the module
Iv. Understanding __name__ Properties : can be used to determine whether the other modules are called
Is the result of running test.py directly (self-invocation)
Is the result of running call.py directly (other module calls)
Five. Custom Module : Non-system comes with the module
The Python version used in this article is 2.7.10and the tool is pycharm
Python: Understanding Modules