Answer the question
In order to leave comments, you need to log in
How to pass arguments to a python file from the command line?
Hello, I have the following bat file
python C:\test.py
called load.
I need to make it so that I can pass arguments to the file directly from the command line, for example:
if the file is test.py:
print(d,c,b,a)
then load 1 2 3 4 on the command line should output 4 3 2 1. The question is how to get these a ,b,c,d.
edit:
Tried to solve with sys.argv method, but it only returns the path to the file.
Answer the question
In order to leave comments, you need to log in
For the simple version:
import sys
print(sys.argv[1])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question