tools

import sys 
import os

command =sys.argv
print(command)
if len(command) > 1 : #Indicate that there are parameters passed in
cmd1 =command[ 1]
if cmd1 == '--help' :
print( 'This is a help document ' 'This python file explains the role of sys.argv' ) elif cmd1 == 'os' : print( 'The current operating system is %s' %sys.platform) else: print( 'The input command is wrong') else: print( 'Pass in a parameter when running Python' 'eg' 'python xx.py install') # sys.argv # Used to get the parameters passed in when running the python file on the command line, it is a list














# This list has one parameter by default, which is the current file name

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325262728&siteId=291194637