我尝试加载JSON文件,但无法使用空间。
如果我尝试加载!ping Steve
正常工作,!ping "George Stephen"
正常工作,但是如果我尝试加载!ping George Stephen
正常工作,则失败。
json文件示例
{"people": [
{"Name": "Steve", "Sex": "Male", "age": "30"},
{"Name": "Rachel", "Sex": "Female", "age": "25"},
{"Name": "George Stephen", "Sex": "Male", "age": "22"} ] }
@bot.command(pass_context=True)
async def ping(ctx, namesList):
with open('data.json') as json_file:
d = json.load(json_file)
for p in d['people']:
if(p['Name'] in (namesList)):
await bot.send_message(ctx.message.channel, p)