How to pass dictionary as command line argument to Python script? I need to get dictionary where key is string and value is list of some elements – for example to look like:
Here's another method using stdin. That's the method you want for a json cgi interface (i.e. having a web server pass the request to your script):
Python:
import json, sys
request = json.load( sys.stdin )
...
To test your script from a Linux terminal:
echo '{ "key1": "value 1", "key2": "value 2" }' | python myscript.py
To test your script from a Windows terminal:
echo { "key1": "value 1", "key2": "value 2" } | python myscript.py