The difference between the import SYS and the FROM sys import argv of Python

Source: Internet
Author: User

This is the answer of a great God seen on the Internet:

SYS is a module, contains "system functionality". SYS.ARGV is a list of containing your script ' s command line arguments. One-to-use it would is to write the import sys and then sys.argv to access it.

From module import names are an alternative-to-import a module that allows your to access the given names without naming The module. That's writing from SYS import ARGV allows do just write argv whereas import sys would require you to write SYS.ARGV instead.

The SYS is a module that contains some system functions, and Sys.list is a list of some of the command-line arguments your script wants to run, and one way to use it is to write: SYS.ARGV.

The From module import names is a way to import a module in disguise, allowing you to directly use the variable name (names) without importing the module name. From sys import ARGV this way allows you to use argv directly, without having to write this sys.argv again.

Here's what you understand:
Import SYS takes all the functions and parameters contained in the SYS module, whether you need it or not, to include it, just like the # include () directive in the C language
The FROM SYS import ARGV imports the argv parameter in SYS and does not include all of the functions and variables in the SYS module, only the argv variable is imported, which is what is called to keep your program streamlined. When you use the argv parameter in a script, the argv parameter in SYS is called.

The difference between the import SYS and the FROM sys import argv of Python

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.