/*************************************** ******************************
* Function: Test getopt* Author: Samson* Date: 11/30/2011* Test Platform:* GNU Linux version 2.6.29.4* GCC version 4.4.0 20090506 (Red Hat 4.4.0-4) (GCC)*************************
Format
Getopt (args, options[, long_options])
1.args represents the parameters to resolve.2.options indicates the character to be recognized by the script. The characters are delimited by ":" and Must End with ":", such as "A:B:C:".3.long_options
This article mainly introduces the Python getopt detailed and simple examples of relevant information, the need for friends can refer to the following
Python getopt detailed
Function Prototypes:
Getopt.getopt (args, shortopts,
format
Getopt (args, options[, long_options])
1.args represents the parameter to parse.2.options indicates the character that the script will recognize. The characters are separated by ":" and Must End with ":", for example "A:B:C:".3.long_options
getopt is a function of getting program startup parameters under Linux#include int getopt (int argc, char * const argv[],const char *optstring);extern char *optarg;extern int Optind, opterr, optopt; using the global Parameters Optarg, Optind,opterr,
Getopt is the processing module for parameter options in Python3 in the C language format. Getopt can handle short and long options:-A short option--add long option The processing process is divided into three steps: The first step is to get the
Action: Handling command-line argumentsFunctions: Getopt (args, shortopts, longopts = [])Parameter args is generally sys.argv[1:] shortopts short Format (-) longopts long Format (--)Example:Script File test.py contentImport getoptImport Sysdef usage
Getop in PHP is used to receive cmd parameters.For example, when you need PHP debugging in linxu, you often need parameter debugging.Getopt is a command that can be passed in with parameters.
Usage:Array
Getopt(String
$ Options[, Array
$
In this paper, we describe Python's method of using getopt to parse command line input parameters and share them for your reference.
The specific instance code is as follows:
Import getopt Import sys config = { "input": "", "Output": ".", }
Python getopt and simple examples
Python getopt
Function prototype:
getopt.getopt(args, shortopts, longopts=[])
Parameter description:
Args: args is the list of parameters to be parsed. Sys. argv [1:] is generally used to filter out the first
PHP uses getopt () to parse cli parameters, getoptcli
The getopt () in the PHP manual is described as follows:
/**
* Gets options from the command line argument list
* @ Link http://php.net/manual/en/function.getopt.php
* @ Param string $ options
In the daily work of the need to write a lot of Python script, when the function of the script is more, or the need for external input parameters, if the parametersName and parameter values can be executed in a way that makes the script seem more
The Getopt module is used to extract command-line options and parameters, i.e. SYS.ARGVcommand-line options make the program more flexible in its parameters. Supports short option mode and long option modeFor example python scriptname.py-f ' hello '-
Python getopt module, which is a function specifically designed to handle command-line arguments getopt (args, shortopts, longopts = []) parameters args are generally sys.argv[1:]shortopts short format (-)On the command line, enter:Python
Introduction: This is the PHP getopt function of the detailed page, introduced and PHP, related knowledge, skills, experience, and some PHP source code and so on.
class= ' pingjiaf ' frameborder= ' 0 ' src= '
Getopt is easier than configparser.
The following is the getopt resolution method.
Import OS, sys, getopt def test (): ARGs = sys. argv [1:] # parses the command line parameters. A: BC: indicates that there are three parameters-a-B-c, -a-c
The PHP manual getopt () is described below:/*** Gets options from the command line argument list* @link http://php.net/manual/en/function.getopt.php* @param string $options Each character in this string would be used as option characters and*
#!/usr/bin/env python #-*-coding:utf8-*-import getopt #函数getopt (args, shortopts, longopts=[]) "" "parameter args is typically s Ys.argv[1:] shortopts Short Form (-) longopts long Format (-) command line input: Python test.py-i 127.0.0.1-p test
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.