Python dictionary 字典 常用法

Python dictionary 字典 常用法

d = {}

d.has_key(key_in)       # if has the key of key_in

d.keys()                       # keys list

d.values()            # values list

d.get(key_in,[defualt])          # it will return 'NoneType' or [default] if with the second argument, if dict has no key of key_in, it will raise error with d[key_in]

if d:                              # if d is empty, it will be False

上一篇:DJ Java Decompiler


下一篇:04.Dictionary字典键值对集合