我的python代码如何将json值全部改为0。
代码
str(ctx.author.id): score
这是我想要的结果:
str(ctx.author.id): 4
str(ctx.author.id): 3
str(ctx.author.id) 是可以随时更改的。
str(ctx.author.id) 由 18 位数字组成
答案 0 :(得分:0)
您希望所有 JSON 值都为 0?那你为什么在例子中给出 3、4
无论如何,这就是你将如何做到的
import json
with open("filename.json") as f:
data = json.load(f)
for i in data:
data[i] = 0
with open("filename.json", "w") as f:
json.dump(data, f, indent=4)