Woody's Python Study Notes 4, woodypython
Python Module
Import Statement
To use the Python source file, you only need to execute the import Statement in another source file. The syntax is as follows:
Import module1
When the interpreter encounters an import Statement, the module will be imported in the current search path. The search path is a list of all directories that the interpreter will first search.
From... Import Statement
The from Statement of Python allows you to import a specified part from the module to the current namespace. The syntax is as follows:
From modname import name: for example, to import the function of the fib module:
From fib import maid
When importing a Python module, the interpreter searches for the module in the following order:
First, it is the current directory. If it is not in the current directory, python searches for each directory under the shell variable PYTHONPATH. If it cannot be found, python will view the default path, in unix, the default path is/usr/local/lib/python.
Which of the following is the Python core programming (version 2nd) and Python learning Manual (version 4th) that is more suitable for beginners and practical?
I used core programming at the time. If you want to learn what you want, you can search for information on the Internet. These two books are the most basic syntax. For example, python cookbook.
Which of the following is the Python core programming (version 2nd) and Python learning Manual (version 4th) that is more suitable for beginners and practical?
The python learning manual is better, and the python core programming book is not good! It is best to read the official documentation. Of course, it is better to use English.