相关疑难解决方法(0)

如何在Python的字典中打印给定值的键?

例如,假设我们有以下字典:

dictionary = {'A':4,
              'B':6,
              'C':-2,
              'D':-8}
Run Code Online (Sandbox Code Playgroud)

如果给出它的价值,你如何打印某个键?

print(dictionary.get('A')) #This will print 4
Run Code Online (Sandbox Code Playgroud)

你怎么能倒退呢?即,不是通过引用键获取值,而是通过引用该值来获取键.

python dictionary key

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

标签 统计

dictionary ×1

key ×1

python ×1