Python:dict(zip(key,value))拼接JSON

Python:dict(zip(key,value))拼接JSON

import json

config_key = []
config_value = []

config_key.append("connector.name")
config_key.append("connector.class")

config_value.append("mysql-unified_view_test-connector11")
config_value.append("io.debezium.connector.mysql.MySqlConnector")

config_dic = dict(zip(config_key, config_value))
print(config_dic)
#输出如下所示:
#{'connector.name': 'mysql-unified_view_test-connector11', 'connector.class': 'io.debezium.connector.mysql.MySqlConnector'}

config_json = json.dumps(config_dic)
print(config_json)

# 输出如下所示:
# {"connector.name": "mysql-unified_view_test-connector11", "connector.class": "io.debezium.connector.mysql.MySqlConnector"}
上一篇:WPF 10天修炼 第二天- XAML语言


下一篇:LuoguP4211 [LNOI2014]LCA 题解