Using Argparse In Python To Parse An Entire Json
I am trying to parse an entire Json in a simple argument using ARGPARSE library, the thing is that it stops suddenly when it hits different elements inside the son, like '-' and '
Solution 1:
Use one single-quote to wrap the command line argument rather than triple-double-quotes. The triple-double-quotes are a Python syntax, not a shell syntax.
python parse.py -contenido '{"desde": "2020-03-01","hasta": "2020-03-31","plantas": [{"id": 6,"nombre": "MDS","inversores": [{"id": "Ingeteam 0237","energa": 2152.8070,"pr": 61.5299,"disponibilidad": 81.1770,"factorPlanta": 15.5313}, {"id": "Ingeteam 0538","energa": 2167.5898,"pr": 61.9315,"disponibilidad": 81.0459,"factorPlanta": 15.6381}, {"id": "Ingeteam 0236","energa": 2168.1885,"pr": 61.9511,"disponibilidad": 80.9856,"factorPlanta": 15.6426}, {"id": "Ingeteam 0563","energa": 2206.8702,"pr": 63.0825,"disponibilidad": 80.9455,"factorPlanta": 15.9219}]'
You may also use one double-quote to wrap the argument, but you'll need to escape each double-quote in the argument.
Post a Comment for "Using Argparse In Python To Parse An Entire Json"