Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/344.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将python字符串插入JSON数组而不操纵该字符串_Python_Arrays_Json - Fatal编程技术网

将python字符串插入JSON数组而不操纵该字符串

将python字符串插入JSON数组而不操纵该字符串,python,arrays,json,Python,Arrays,Json,想要在JSON数组中插入字符串 字符串是[“accom\u ap”,“inside\u Vince”]到: "availabilityTags": [ "accom_ap", "inside_venue" ] 作为一项工作,我把绳子拉开,然后一次插一根。。。值“accom\u ap”,然后附加第二个“inside\u Vince”,依此类推 是否需要将整个字符串插入数组?我曾经 array = json.dumps(

想要在JSON数组中插入字符串

字符串是
[“accom\u ap”,“inside\u Vince”]
到:

 "availabilityTags": [
    "accom_ap",
    "inside_venue"
]
作为一项工作,我把绳子拉开,然后一次插一根。。。值
“accom\u ap”
,然后附加第二个
“inside\u Vince”
,依此类推

是否需要将整个字符串插入数组?我曾经

array = json.dumps(stg)
转换它,但仍然不工作

将数组视为空

建议

Tks.

使用
json.loads()
将json字符串转换为Python字典或列表。然后将列表放入字典,并将其转换回JSON

stg = {}
json_string = '["accom_ap", "inside_venue"]'
tags = json.loads(json_string)
stg['availabilityTags'] = tags
new_json_string = json.dumps(stg)

你的问题不清楚。要插入的数组已经具有要插入的值。请你回答这个问题,说明实际投入和预期产出。