小编Bla*_*ool的帖子

为什么python中的链式字典.get()在提供的默认值不是元组时返回一个元组?

Python 2.6.6当我在.get的结果上调用.get结果是一个元组.这对我没有意义.例:

box = {}.get('test1',{}).get('test2','hrmm'),
print type(box)
Run Code Online (Sandbox Code Playgroud)

打印出来

<type 'tuple'>
Run Code Online (Sandbox Code Playgroud)

这对我没有意义.显然,第二个get中的默认值是一个简单的字符串.什么赋予了什么?感谢任何见解.

python dictionary tuples get chained

7
推荐指数
2
解决办法
1831
查看次数

标签 统计

chained ×1

dictionary ×1

get ×1

python ×1

tuples ×1