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

Python command line parameters sys.argv

巴扎黑
Release: 2017-05-21 11:10:37
Original
1691 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template