Python Control Flow-Import module

Source: Internet
Author: User

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

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.