Sep-27-2020, 06:25 AM
I am trying to pass a argument to command line for running a python program which takes list of Field Objects and send an email. The program is running fine when the list of objects is already set in my program.
Python Version :3.8.5
a=[{"name": "productname_0", "type": "html", "content": "A Cool Shirt"}, {"name": "productname_1", "type": "html", "content": "Some Nice Shoes"}, {"name": "productname_2", "type": "html", "content": "A Trendy Hat"}, {"name": "productprice_0", "type": "html", "content": "20.99"}, {"name": "productprice_1", "type": "html", "content": "50.99"}, {"name": "productprice_2", "type": "html", "content": "FREE"}] sendmail(a)But when I pass this list in command line ,it did not work for me.
a = json.loads(sys.argv[1]) sendmail(a)Running Program from Command Line
mailscript.py '[{"name": "productname_0", "type": "html", "content": "A Cool Shirt"}, {"name": "productname_1", "type": "html", "content": "Some Nice Shoes"}, {"name": "productname_2", "type": "html", "content": "A Trendy Hat"}, {"name": "productprice_0", "type": "html", "content": "20.99"}, {"name": "productprice_1", "type": "html", "content": "50.99"}, {"name": "productprice_2", "type": "html", "content": "FREE"}]'Error : json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Python Version :3.8.5