Skip to content

如何快速调换字典中的key和value #34

@Sogrey

Description

@Sogrey

如何快速调换字典中的key和value

d = {'a':1,'b':2}
print({v:k for k,v in d.items()})  # {1: 'a', 2: 'b'}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions