Python Basics-Modules

Source: Internet
Author: User

1. What is a module?

Can be understood as a py file is a module, such as xiaoming.py is a module, want to introduce it,

So just write the import xiaoming in the code.

2. The module first queries from the current directory, if no more query by Path Order (Sys.path)

3. A module will only be imported once, no matter how many times you import it. This prevents the import module from being executed over and over.

#调用模块
Import sum

#调用模块里的方法
Print (Sum.add_two_num)

#from ... import

The FROSM statement in 1.python lets you import a specified section from a module

2.from...import* all the contents of a module are imported

#要导入模块sum中的add_two_num函数

From sum import add_two_num

#直接调用方法

Print (Add_two_num (2,2))

Python Basics-Modules

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.