The method of referencing packages in python:
In python, you can use the "import package name" statement to reference the package
Example: introducing time
import time
The package can also be referenced by "from package name import class name"
Example: Introducing the time.time class
from time import time
Content expansion:
What is Python Package
How to distinguish that the directory you see is a Python Package package? It's actually very simple. You just need to see if there is a "init.py" file under this directory. If there is, then it is a Python Package package. If not, just say what you see is an ordinary directory, as shown in the figure below. You can see that "calcuate" and "Log" are a Python Package, and "yinzhengjie" is a directory, and the judgment is based on whether it contains the_init__.py file
Python is a flexible language. It can also be said that python is a glue language. As the name suggests, it can import all kinds of packages. Python packages can be said to be the most of all languages. Of course, most of the import packages are for faster, more convenient and more efficient. For Python lovers who are just getting started, the first contact should be the way that import directly imports the package. For example, import time is to import the time package of python. The methods in this package can handle most of the time encountered in our projects The problem.
So far, this article on how to cite a package in python is introduced. For more related python citation methods, please search for ZaLou.Cn's previous articles or continue to browse the related articles below. Hope you will support ZaLou more in the future. Cn!
Recommended Posts