所以,今天早些时候我发了一篇关于这个的帖子,我关注了one of the answers,但它仍然不起作用。你知道吗
我有个文件叫金额.json使用用户id
代码总是跳转到声明中,声明用户没有帐户,而实际上我有。你知道吗
使用balance命令,它第一次工作,然后停止工作并告诉我一个地址已经存在,这意味着它反复使用相同的if语句,反复创建一个帐户。你知道吗
我遵循了其中一个答案,现在json根本没有被写入。。你知道吗
代码:
@client.event
async def on_ready():
with open('amounts.json') as f:
old_amounts = json.loads(f)
new_amounts = {}
for d in old_amounts:
for k, v in d:
amounts[k] = amounts.get(k, 0) + v
with open('amounts.json') as f:
json.dump(amounts, f)
@client.command(pass_context=True)
async def balance(ctx):
user_id = ctx.message.author.id
global amounts
if user_id not in amounts:
block_io.get_new_address(label=user_id)
knee = block_io.get_address_balance(label=user_id)
s1 = json.dumps(knee)
d2 = json.loads(s1)
d2['data']['available_balance']
embed=discord.Embed(description="Bitcoin: btc here \n\nLitecoin: here\n\nDogecoin: {}".format(d2['data']['available_balance']), color=0x00ff00)
await client.say(embed=embed)
with open('amounts.json', 'w+') as f:
json.dump(amounts, f)
elif user_id in amounts:
knee = block_io.get_address_balance(label=user_id)
s1 = json.dumps(knee)
d2 = json.loads(s1)
d2['data']['available_balance']
embed=discord.Embed(description="Bitcoin: btc here \n\nLitecoin: here\n\nDogecoin: {}".format(d2['data']['available_balance']), color=0x00ff00)
await client.say(embed=embed)
with open('amounts.json', 'w+') as f:
json.dump(amounts
编辑:
问题仍未解决。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐