Home  >  Article  >  Backend Development  >  An introduction to how to obtain command line parameters

An introduction to how to obtain command line parameters

伊谢尔伦
伊谢尔伦Original
2017-06-12 09:53:472222browse

sys.argv[] is used to obtain command line parameters, sys.argv[0] represents the file path of the code itself; for example, enter "python test.py -help" on the CMD command line, then sys.argv[ 0] means "test.py". sys.startswith() is used to determine what an object starts with. For example, entering "'abc'.startswith('ab')" on the python command line will return True. The following example reference: #!/usr/ local/bin/env python import sys def readfile(filename): '''Print&

1. Detailed explanation of how to use sys.argv[]

An introduction to how to obtain command line parameters

Introduction: sys argv[] is used to obtain command line parameters. sys argv[0] represents the file path of the code itself; for example, enter python test py -help on the CMD command line, then sys argv[0 ] stands for test py. sys startswith() is used to determine what an object starts with, such as in

2. Python method of obtaining command line parameters

An introduction to how to obtain command line parameters

Introduction: This article explains how to use python to obtain command line parameters and what methods are available.

3. Summary of python’s method of obtaining command line parameters

An introduction to how to obtain command line parameters

##Introduction: Introducing python's method of obtaining command line parameters: getopt module and argparse module.

4. python Get command line parameter function

An introduction to how to obtain command line parameters

##Introduction: A function to obtain the parameters and quantity of the command line under perl.

5. Detailed explanation of the use of

sys.argv[]

An introduction to how to obtain command line parameters

Introduction: sys.argv[] is used to obtain command line parameters, sys.argv[0] represents the file path of the code itself; for example, enter python test.py -help on the CMD command line, then sys.argv [0] represents test.py. sys.startswith() is used to determine what an object starts with, such as...

6.

Python sys.argv usage example

Introduction: This article mainly introduces Python sys.argv usage examples. sys.argv[] is used to obtain command line parameters. sys.argv[0] represents the file path of the code itself. , others are used to indicate obtaining input parameters. Friends who need it can refer to

[Related Q&A recommendations]:

Get the command line in Python Why can’t I enter else when processing parameters? Can anyone enlighten me?

The above is the detailed content of An introduction to how to obtain command line parameters. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn