如果 collections.defaultdict 不可用怎么办?
Solaris python 2.4.3:
from collections import defaultdict
不存在..
请告知使用多级字典的替代方法:
dictOut['1']['exec'] = 'shell1.sh'
dictOut['1']['onfailure'] = 'continue'
...
dictOut['2']['exec'] = 'shell2.sh'
dictOut['2']['onfailure'] = stop'
非常感谢 阿普洛姆
Solaris python 2.4.3:
from collections import defaultdict
does not exist..
Please advise what could be an alternative to use multi-level dictionaries:
dictOut['1']['exec'] = 'shell1.sh'
dictOut['1']['onfailure'] = 'continue'
...
dictOut['2']['exec'] = 'shell2.sh'
dictOut['2']['onfailure'] = stop'
many thanks
applom
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
设置默认值
?setdefault
?作为
setdefault
的替代方案,如果您想要额外级别的字典功能,请尝试As an alternative to
setdefault
, if you want extra level of dictionary goodness, try在过去 24 小时内使用 looks-like-it-works 代码 进行了回答(由搜索“defaultdict”,选择“最新”或“活动”订单)
Answered with looks-like-it-works code within the last 24 hours (found by searching for "defaultdict", choose "newest" or "active" order)
我只是想知道为什么不使用单级字典和元组作为哈希键?
I just wonder why not to use single level dict with tuple as hash key?