Home  >  Article  >  Backend Development  >  Python command line parameters sys.argv

Python command line parameters sys.argv

巴扎黑
巴扎黑Original
2017-05-21 11:10:371660browse

The command line parameters are obtained through sys.argv[]. sys.argv[0] is the path of the code file itself, so the parameters start from 1. For example, the setting parameters are: spe

Python code:


import os, sys
os.system(sys.argv[
1])

Execute python xxx.py with parameters spe

os.system is used to execute the command line. Therefore, the program will receive the first parameter spe, and then execute spe on the command line. In this way, spe (Python IDE) will be opened.

The above is the detailed content of Python command line parameters sys.argv. 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