我正在嘗試在這里訪問字典的鍵
{'application_id': '467377486141980682',
'attachments': [],
'author': {'avatar': '25cb9058944599f9f1ba15279f9e4a8f',
'bot': True,
'discriminator': '0000',
'id': '964810500611375104',
'username': 'Sparky99'},
'channel_id': '790967460039491644',
'components': [],
'content': '73561',
'edited_timestamp': None,
'embeds': [],
'flags': 0,
'id': '976330290698006528',
'mention_everyone': False,
'mention_roles': [],
'mentions': [],
'pinned': False,
'timestamp': '2022-05-18T03:48:00.642000 00:00',
'tts': False,
'type': 0,
'webhook_id': '964810500611375104'}
除了用戶名之外,我可以訪問所有這些。
當我運行時,它會像 if 不存在一樣dic.get("username")回傳,但我可以使用所有其他元素訪問nonedic.get()
注意:如果我需要在問題中添加更多資訊,請告訴我。
uj5u.com熱心網友回復:
username不是該字典中的鍵。有一個鍵author,它的值是一個字典,你可以在其中找到username.
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/477319.html
