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"}