The-m parameter of Python

Source: Internet
Author: User

1, when starting the Python script in the command line, often use the-m parameter, then-m what role?

2, first look at the information given by Python--help:

Run Library module as a script (terminates option list)

This means that the Python module in the library is used as a script to run.

3. Common examples

Python-m simplehttpserver    #python2 start a simple HTTP server python-m http.server    #  Start a simple HTTP server in Python3

4. What is the use of the module as a script to start?

    1. Python xxx.py
    2. Python-m xxx.py

Here are two ways to load a py file:
1 is called direct run
2 equivalent to import, called as a module to start

Different ways to load the Py file are mainly affected by the Sys.path property. Sys.path equivalent to path in Linux

>>>ImportSYS>>>sys.path["','D:\\python3\\lib\\site-packages\\django-1.10.1-py3.5.egg','d:\\python3\\lIb\\site-packages\\psycopg2-2.6.2-py3.5-win32.egg', 'D:\\python3\\python35.zip', 'D:\\python3\\dlls','D:\\python3\\lib','D:\\python3','D:\\python3\\lib\\site-packages']

This is the context in which the current Python parser is running, and the Python parser will look for a dependent library in these directories.

The detailed difference can refer to this post-->http://www.cnblogs.com/xueweihan/p/5118222.html

The-m parameter of Python

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.