Tools, FAQ, Tutorials:
sys.argv - Command Line Argument List
How to retrieve command line arguments with sys.argv list?
✍: FYIcenter.com
If execute a Python script file with the "python" command,
you can use the sys.argv list to retrieve command line arguments.
Note that the first argument, sys.argv[0], represents the Python script file name.
Here is a Python script file example, the displays command line arguments:
import sys
print("Python version: "+sys.version)
print("Command line arguments:")
for i, e in enumerate(sys.argv):
print(" sys.argv["+str(i)+"]: "+e)
You can run it with the "python" command:
C:\fyicenter>python echo_argv.py apple orange Python version: 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:14:34) Command line arguments: sys.argv[0]: echo_argv.py sys.argv[1]: apple sys.argv[2]: orange
⇒ 're' Module - Regular Expression Operations
⇐ Printing Python Engine Information
2018-11-11, ∼2495🔥, 0💬
Popular Posts:
How to use "link" command tool to link objet files? If you have object files previously compiled by ...
What is the Azure AD v1.0 OpenID Metadata Document? Azure AD v1.0 OpenID Metadata Document is an onl...
How to use the Atom Online Validator at w3.org? w3.org feed validation service is provided at http:/...
How To Read the Entire File into a Single String in PHP? If you have a file, and you want to read th...
How To Break a File Path Name into Parts in PHP? If you have a file name, and want to get different ...