返回顶部

收藏

Dictionary exists fetch and non-exist fetch

更多
Matrix = {}

Matrix[(2,3,4)] = 88

Matrix[(7,8,9)] = 99

print Matrix

print Matrix.get((2,3,4), 0)          # exists-fetch and return

Matrix.get((2,3,6), 0)          # does not exist-use default arg

标签:Python,Dictionary

收藏

0人收藏

支持

0

反对

0

发表评论