相关疑难解决方法(0)

在python中切换字典中的键和值

说我有这样的字典:

my_dict = {2:3, 5:6, 8:9}
Run Code Online (Sandbox Code Playgroud)

有没有办法可以切换键和值来获得:

{3:2, 6:5, 9:8}
Run Code Online (Sandbox Code Playgroud)

python dictionary key

43
推荐指数
5
解决办法
5万
查看次数

标签 统计

dictionary ×1

key ×1

python ×1