Home Python 基本数据格式的基本操作hash[],get(..),none..获得uniqlist
Post
Cancel

Python 基本数据格式的基本操作hash[],get(..),none..获得uniqlist

refer to: https://flexiple.com/python/check-if-key-exists-in-dictionary-python

基本跟ruby 一样

a = {'one': 1, 'two': 2} 

a['one']  # => 1

a.get('not-exist-key')   # =>  None

a['not-exist-key']  # => 报错

把一个list转换为uniq list:

a = "123"

set(list(a))

This post is licensed under CC BY 4.0 by the author.