我有一个列表存储在一个json文件1中有相同的键,但每个重复有两个不同的值键如下所示。我想插入一个MySQL数据库,其中键匹配某个列,然后在从另一个json文件2获取密钥后,将这两个值插入到列x和y中。这是因为我一个尝试更新从JSON文件2创建一个表,包含从JSON从http://stardict.sourceforge.net/Dictionaries.php下载列表附加值文件1插入从一个包含相同键的字符串json列表中的值到列表中的两个不同的值到一个MYSQL数据库
json file 1
[{"a": 0.022222222222162753,
"b": 0.022222222222162753,
"c":0.022222222222162753,
"d": 0.022222222222162753,
"e": 2.6761620240410805e-12,
"f": 0.022222222222162753},
{"a": 0.022222222222162753,
"b": 0.022222222222162753,
"c": 0.022222222222162753,
"d": 0.022222222222162753,
"e": 0.022222222222162753,
"f": 0.022222222222162753}]
json file 2
{"a":1,
"b": 2,
"c": 3,
"d": 4,
"e": 5,
"f": 6}
这里是根据列我加载结果到MySQL数据库代码匹配表单中的重复键,Key | value one |在找到另一个json文件中的键值后的值二。
for line3 in open("json file 2.json"):
jline3=json.loads(line3)
url3 =jline1["url"]
for line4 in open("json file 1.json"):
jline4 = json.load(line4)
computedHITS=jline2[url3]
"""cursor.execute("""
""" UPDATE `RANKED`.`EVALINDEX`
SET `HITS`= %s
WHERE `URL` = %s """
""", (computedHITS, url3))"""
print "Number of rows inserted: %d" % cursor.rowcount
db.commit() """
你有什么解决方案的字典? – Nilesh 2014-09-04 04:16:40
现在让我们直接添加吧 – Mover 2014-09-04 04:22:44
还不清楚哪些不起作用?请在没有工作的地方给出问题陈述 – Nilesh 2014-09-04 04:36:01