<分区> 分区>
我喜欢函数 get,它可以提供默认值,但它只适用于字典。
s=dict{}
s.get("Ann", 0)
我为列表写了一些类似的东西。这个函数在Python3.4中已经存在了吗?
def get(s, ind):
return len(s)>ind and s[ind] or 0
<分区> 分区>
我喜欢函数 get,它可以提供默认值,但它只适用于字典。
s=dict{}
s.get("Ann", 0)
我为列表写了一些类似的东西。这个函数在Python3.4中已经存在了吗?
def get(s, ind):
return len(s)>ind and s[ind] or 0