【dict】get函数

dict中的get函数

  • dict.get('值',None)
  • get函数需要有一个变量接受
  • 一般用来判断值是否存在,若不存在则返回None
  • None可以自定义为字符串,数字
dic = {"amd": "yes", "intel": "yyds"}

ret = dic.get('amd', None)
print(ret)
ret = dic.get('yes', "Not find this")
print(ret)

 

 

 

 

posted @ 2022-06-10 00:45  淫鬻  阅读(98)  评论(0编辑  收藏  举报