I am trying to run a Python script a.py from another Python script scheduler.py and I want to pass a list as argument something like:
Scheduler.py:
t = {"code": 161123134, "name": "task2", "domain": "www.google.com", "type": "Type1", "keywords": ["bai2", "yin4", "jiao3", "yi8", "ping1", "tai3"]}
hourTasks = json.dumps(t)
os.system("python a.py " + hourTasks)
a.py
task = sys.argv[1:]
task = json.loads(task)
However It gives me an error the JSON object must be str, bytes or bytearray, not 'list'. Anyone know what the problem is?
a.py, and use it as a module instead. Otherwise, consider using thesubprocessmodule instead ofos.system().taskinjson.loads(task)is a list, not a string.sys.argv[1](the first argument), notsys.argv[1:](a list containing the first, and any other, arguments).