I am having trouble with passing a string argument to a Python script.
I need to pass a string in this format: "{"test_key_1": [1, 3], "test_key_2": [5]}"
but when I am doing this:
test_script.py --test_arg "{"test_key_1": [1, 3], "test_key_2": [5]}"
I am getting this string inside the script:
'{test_key_1: [1, 3], test_ket_2: [5]}'
Why did my double quotes disappear?
I need to do json.loads(string_argument) after I get the argument, but it fails because of the wrong format.
>Solution :
You need to escape the double quotes like this:
test_script.py --test_arg "{\"test_key_1\": [1, 3], \"test_key_2\": [5]}"
or like just change the delimiters like this:
test_script.py --test_arg '{"test_key_1": [1, 3], "test_key_2": [5]}'