Original link: https://chegva.com/5444.html
The searched modules are compiled into pyc bytecode files
run the imported module
Reload an already imported module
Install and configure Anaconda
▽ The searched modules are compiled into pyc bytecode files
""" When importing a module using the import statement, if the module has not been imported, firstly, the interpreter will search for the module according to a certain path; secondly, the searched module may be compiled into a pyc bytecode file. When the searched When the module is imported for the first time, it will be compiled into a pyc bytecode file. The pyc bytecode file is stored in the directory __pycache__ in the same directory as the module, and its naming format is: module name.cpythonーVersion number.pyc.In this way, the bytecode file of the module is cached. When the module is loaded again, if the module has not changed, there is no need to compile the searched module into a pyc bytecode file, but directly Read the pyc bytecode file in the cache to improve loading speed"""
▽ Run the imported module
""" When importing a module using the import statement, if the module has not been imported, firstly, the interpreter will search for the module according to a certain path; secondly, the searched module may be compiled into a pyc bytecode file; finally, execute Compile the generated bytecode file to run the module. When importing a module in a package, the __init__.py in the package will be imported first, so before running the imported module, it will start from the top-level parent package, first in order Run __init__.py in all parent packages."""
▽ Reload modules that have been imported
""" After importing a module using the import statement, if you make changes to the module and then import the module again using the import statement, the changes to the module will have no effect. On the interactive command line: >>> import mod >>> mod.v Modify mod.py, in the interactive command line: >>> import mod >>> mod.v"""""" After importing a module using the import statement, if the module Modified, you can call the standard library function reload to reload a module that has already been imported. On the interactive command line: >>> import importlib >>> importlib reload(mod) >>> mod.v"""
▽ Install and configure Anaconda
"""1. What is Anaconda and why do you need to install Anaconda? We often use many third-party libraries for Python. If you use the tool pip3 to install one by one, it will not only take time and effort, but also consider compatibility. Anaconda is a Python-based library A platform for data processing and scientific computing, it has built-in many useful third-party libraries. After installing Anaconda, it is equivalent to automatically installing a large number of third-party libraries, so you can directly import modules in these third-party libraries." """""2, Anaconda installation and configuration official website download address: https://www.anaconda.com/download Anaconda is cross-platform. The installer will add the bin directory under the Anaconda installation directory to the system environment variable PATH For example: # added by Anaconda3 5.0.1 installer export PATH="/Users/zhangrongchao/anaconda3/bin:$PATH" Therefore, after Anaconda is installed, its own Python will be used, thus: (1) In the command The python3 entered in the line comes from: <Anaconda installation directory>/bin (2) Third-party libraries installed using the tool pip3 will be installed to: <Anaconda installation directory>/lib/python3.x/site-packages"" """"3, Anaconda's third-party library management tool conda Anaconda uses the tool conda to manage third-party libraries, similar to the tool pip3. Conda related commands: (1) View the help information of conda: conda (2) List All installed third-party libraries conda list (3) Fuzzy search for a third-party library conda search xxx (4) Install the specified third-party library (and its version number) conda install xxx(conda install xxx=yy) (5) Upgrade the specified third-party library conda update xxx (6) Uninstall the specified third-party library (and its version number) conda remove xxx(conda remove xxx=yy) (7) After viewing conda Help information for a command conda "command" --help """
This article is reprinted from: https://chegva.com/5444.html
This site is for inclusion only, and the copyright belongs to the original author.