如何从 Python 中的字典中检索数据?

How to retrieve data from dict in Python?

当我点击树视图项目时它输出

{'text': 1, 'image': '', 'values': [1, '3:18:00', 'pm'], 'open': 0, 'tags': ''}

如何检索 1 或 pm 等特定值?我用了


    queryResultTable.bind('<ButtonRelease-1>', select_item)

    def select_item(a):
        itemlibrary = queryResultTable.focus()
        print(queryResultTable.item(itemlibrary))

我尝试了 .get 但无处可去

试试这个:

a = {'text': 1, 'image': '', 'values': [1, '3:18:00', 'pm'], 'open': 0, 'tags': ''}
print(a['values'][0])
print(a['values'][2])

这应该给你:

1
pm