Run Python file with arguments

Asked

Viewed 3,608 times

5

In my program, I do the following operation:

import sys
qtd_ponts = int(sys.argv[1])

I would like to know a practical way to run this file .py passing arguments without needing an IDE, using files .bat for example.

  • In your bat file, just put python.py file [arg1 arg2 ...], no?

  • 1

    yes! it worked! I didn’t think it was that simple. Put as answer.

1 answer

7


To run a script as bat or directly from the console, simply put the following command:

python arquivo.py [arg1 arg2 ...]

Remembering that in the case of Windows, the folder in which python is installed needs to be in the environment variable (path).

  • 1

    Felipão! knows all about python :)

  • Far from it, you still have a lot to learn. (:

Browser other questions tagged

You are not signed in. Login or sign up in order to post.