Home  >  Article  >  Backend Development  >  How to import math library in python?

How to import math library in python?

青灯夜游
青灯夜游Original
2019-05-18 14:16:5638996browse

The Python language divides functions by distinguishing class libraries. Users load appropriate class libraries according to their own needs to complete the required functions. So how to import and load the class library? The following article will take the built-in class library math as an example to introduce the method of loading the built-in class library. I hope it will be helpful to you.

How to import math library in python?

How to import class libraries in python?

Use the keyword import in python to import and load class libraries. Taking the math library as an example, use the following statement to import the math library:

import math

How to import math library in python?

We can use the alias when importing, which can make the code concise

import math as m

How to import math library in python?

To only import specified functions in the class library, you can use the from...import statement

Python's from statement allows you to import a specified part from the module into the current namespace.

from math import sin as  s

How to import math library in python?

If you want to import all the functions of the class library, you can use the from...import* statement

The from...import* statement can import all functions of a module All contents are imported into the current namespace, for example:

from math import *

How to import math library in python?

The above is the detailed content of How to import math library in python?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn