First, the module
1. Meaning a Python program can invoke a basic set of functions, called "built-in functions," including the print (),input (), and len () functions you have seen. Python also includes a set of modules called "Standard Libraries". Each module is a Python program that contains a set of related functions that can be embedded within your program. < Span style= "FONT-SIZE:11.000000PT; font-family: "times New roman" ">2. Syntax form < Span style= "FONT-SIZE:11.000000PT; font-family: "times New roman" "> before you start using a function in a module, you must import the module with an import statement. In the code, the import statement contains the following sections:
(1) Import keyword
(2) The name of the module
(3) optional more module names, separated by commas
< Span style= "FONT-SIZE:11.000000PT; font-family: "times New roman" ">3. Example
#!/usr/bin/env python
#coding: utf-8
Import Random
for I in range (5):
Print (Random.randint (10,100))
import random module, generate 5 x 10-100 randomly integer
second, import module mode
1. Import the module using import and use the module in the statement. The form of a function
(1) call a single module
#!/usr/bin/env python
#coding: utf-8
Import Random
for I in range (5):
Print (Random.randint (10,100))
(2) call multiple modules at the same time
import sys, OS, random
2. Using" from module import * "
#!/usr/bin/env python
#coding: Utf-8
from random import *
for I in range (5):
Print (Randint (10,100))
Python Control Flow-Import module