我想将下面的json正文作为用户输入存储在变量中并传递给变量,它在多行输入中
{ "key1": "value1", "key2": "value2", "key3": "value3", "key4": "value4", "key5": "value5", "key6": "value6", "key7": "value7", "key8": "value8" }
我在下面尝试过
import json
allow = json.dumps(input("Enter your Json body: "))
print(allow)
print(json.loads(allow))
variable = {
"key1": "value1",
"key2": "value2",
"key3": "value3",
"key4": "value4",
"key5": "value5",
"key6": "value6",
"key7": "value7",
"key8": "value8"
}
我需要将多行变量作为同一JSON主体传递给函数。