Skip to content
Advertisement

Command line array argument into a python script

I would like to create a python script and parse a list of command-line arguments.

Specifically, I would like to give it the following arguments and have it read them as an array. Something like this:

JavaScript

where the input array is:

JavaScript

and inside the script, I want to do a “for loop” and and assign the variables in this way:

JavaScript

Advertisement

Answer

You can convert the array to JSON.

In the calling script, do:

JavaScript

and in script.py you parse the JSON

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement