How to import math library in python?

青灯夜游
Release: 2019-05-23 18:46:36
Original
38973 people have browsed it

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
Copy after login

How to import math library in python?

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

import math as m
Copy after login

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
Copy after login

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 *
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!