The key to using command-line arguments is that the shell script needs to interact with the person who is running the script.The bash shell provides command-line arguments to add data values after the command, command line options to modify the
Sys.argv[] is used to get command line arguments, Sys.argv[0] represents the code itself file path, such as the cmd command line input “python test.py-help”, then sys.argv[0] is representative of “test.py”. Sys.startswith ()
Sys.argv[] is used to get command line arguments, Sys.argv[0] represents the code itself file path, such as the cmd command line input “python test.py-help”, then sys.argv[0] is representative of “test.py”. Sys.startswith ()
Variable names can only contain numbers, letters, and underscores, because some variables that contain other characters have special meanings, and such variables are called special variables.For example, $ represents the ID of the current shell
"Copyright Notice: respect for the original, reproduced please retain the source: blog.csdn.net/shallnet, the article only for learning Exchange, do not use for commercial purposes"In a high-level language, a program often takes one or more
People who have been programmed in the C language know that programming in DOS allows you to get the number of command-line arguments and the string of each parameter by using the parameters of the main function, such as
int main(int argv ,char
Describes how python obtains command-line arguments: getopt and Argparse modules.
Python version: 2.7
One, getopt module
The main use of the function in the module:
Options, args = Getopt.getopt (args, shortopts, longopts=[])
Parameter args:
The most important feature of C programs is that all programs are assembled using functions . Main () is called the main function , which is the entry for all programs to run. The rest of the functions are either a parameter or no parameter, which
Learn the C language when you do not understand the use of command-line parameters, in the learning Pyton, and encountered the command line parameters, here a little study, a little understanding of some here to make a record convenient back review
Sometimes we need to write some scripts to handle some tasks, it is often necessary to provide some command line parameters, according to different parameters for different processing, in Python, command line parameters and C language very similar
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.