Python module and module installation

Source: Internet
Author: User

In fact, Python module and module installation and other programming languages, such as: NodeJs, Reactjs the same, but they use the package management tool is not the same, Python with Pip, and node with NPM

Python module

The Python language, like many other programming languages (Nodejs, Reactjs), also has a lot of built-in modules that we can use just to introduce them.

    • SYS module

      # #编写模块# #sys‘a test module‘_author = ‘yehui‘;import sys;def test():    args = sys.argv;    if len(args) == 1:        print("hello world!");    elif len(args) == 2:        print("hello, %s!" % args[1]);    else:        print("too many arguments");if __name__ == ‘main‘:    test();print(test());# hello world!

      The SYS module has a argv variable that stores all parameters of the command line with the list, argv has at least one parameter, and the first parameter is always a. py file.

    • Scope
      In a module, some of our variables and functions want to be used only within the function, then we can use the _ prefix to implement. A function or variable similar to _XXX is non-public.

Installing third-party modules

In Python, installing a third-party module is done through the Package management tool Pip , which is similar to Node's package management tool, NMP. In general, third-party libraries are registered on the official Python pypi.python.org website.
Common installation command format:

    pip install xxx #相应模板的名称

Install common modules
You can directly use Anaconda(official website [https://www.anaconda.com/download/] To download the Gul installation package), a Python-based data processing and scientific computing platform, It has built in a number of very useful third-party libraries, we installed anaconda, it is equivalent to the dozens of third-party modules to install automatically, very easy to use.

Summarize

This part of the individual feel that there is nothing to summarize, and the same as other programming languages. The source of study is also the website Python tutorial of Liu Xuefeng teacher.

Python module and module installation

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.