如何使用键从字典中打印特定值?

时间:2018-10-07 03:10:27

标签: python-3.x boto3

因此,如果运行此命令,我只会得到数百个键和值的列表。

我想知道的是如何从该词典中提取特定值?

即:UserA-来自关键字“用户”

myuser = iam.list_users(
    PathPrefix='/'

看看BOTO3,我想拔出Example用户'Juan'

Expected Output:

{
'Users': [
    {
        'Arn': 'arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/engineering/Juan',
        'CreateDate': datetime(2012, 9, 5, 19, 38, 48, 2, 249, 0),
        'PasswordLastUsed': datetime(2016, 9, 8, 21, 47, 36, 3, 252, 0),
        'Path': '/division_abc/subdivision_xyz/engineering/',
        'UserId': 'AID2MAB8DPLSRHEXAMPLE',
        'UserName': 'Juan',
    },
    {
        'Arn': 'arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/engineering/Anika',
        'CreateDate': datetime(2014, 4, 9, 15, 43, 45, 2, 99, 0),
        'PasswordLastUsed': datetime(2016, 9, 24, 16, 18, 7, 5, 268, 0),
        'Path': '/division_abc/subdivision_xyz/engineering/',
        'UserId': 'AIDIODR4TAW7CSEXAMPLE',
        'UserName': 'Anika',
    },
],
'ResponseMetadata': {
    '...': '...',
},

}

谢谢!

1 个答案:

答案 0 :(得分:1)

打印值

用户-您的字典

用户-字典中的值

  

user = users [“ UserKey”]

     

打印(用户)