Methods of introducing python module

Status module in python programming important, skilled use of the module can greatly reduce the amount of code with minimal code to implement complex functions.

Here are some how to import modules in python programming:

(1) import module name: directly into, where all import function module;                 

import configparser
import time
import sys

         The module can also be here to write your own script name, such as:

#hello.py
def hello1():
print("hello world!")

import hello

(2) from the module name import function name 1 [, function name 2, ...]: import function specific function;

from requests import get
from requests import post
from platform import systey

(3) from the module name import *: All import function, * for all functions;

from wxpy import *

(4) import module as Alias ​​Name: Alias ​​introduced;

import configparser as cf
import time as T
import sys as sy

         

Learning and human, will not valley; product made good, no evil mmol mans.

Guess you like

Origin www.cnblogs.com/xiaoyan-ipython/p/11729693.html