Python function library and function standard library

Source: Internet
Author: User
Tags mathematical functions network function sin website ip

One, the system library provides a library of intrinsic function number characters:

1) Str.islower (): Whether the strings are all lowercase

2) Str.isspace (): Whether the string is empty

3) Help (str): query string function library

4) str.replace (old, new): String substitution function, (can replace only part of the content)

5) Str.isupper (): Judgment is not uppercase

Mathematical functions:

Import Math: The introduction of the math library, not the default, if you want to use mathematical functions, you need to first introduce

1) Math.sin (): Seek sin30° such as Math.sin (3.14/6) Math.sin (MATH.PI/6)

2) Math.PI: To find the PI value

3) Math.pow (n,m): N's M-th square

4) * *: Several parties such as 3**4 3 4-Time Square

Operating system functions

Import OS

OS.GETCWD (): Gets the current working path

Os.listdir (current directory): Gets all the entities in the current directory (document)

Network function library: import socket

1) Get network IP address: socket.gethostbyname (' website IP address ')

2) Help (SOCKET): Query the function library under the socket

Ii. functions provided by third parties

Open source projects provide functions that need to be downloaded and installed online: httplib2 details Baidu related blog

1) Import Urllib:url class

2) Import WebBrowser as Web: Operation Browser. and alias WebBrowser to Web

3) urllib.urlopen (URL). read (); : Open browser and read related content

4) Open (' File name ', ' W '). Write (What you need to write): write the read file to the file

5) WebBrowser. Open_new_tab (' HTML file needed to open '): Open the relevant HTML file through the browser/url

Third, user-defined functions

A module or function that you write yourself

def keyword function_name (parameter):

Without curly braces, you need to use the TAB key to differentiate the block of statements.

Python function library and function standard library

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.