sys.argv Will run from the command line Python The program is in python or python3 The following parameters have been saved in the form of a list .
for example , Here is test.py The content of the document :
import sys
print(sys.argv)
Command line execution :python test.py
Output :
['test.py']
Command line execution :python 'test.py' abc def
Output :
['test.py', 'abc', 'def']
By default, it is separated by spaces , If you want to be a whole , You can put quotation marks on the outside :
Command line execution :python test.py 'abc def'
Output :
['test.py', 'abc def']