Dictionaries are indexed by keys, which can be any immutable type,indexedimmutable,# Dictionari
文章由Byrx.net分享于2019-03-23 06:03:16
Dictionaries are indexed by keys, which can be any immutable type,indexedimmutable,# Dictionari
# Dictionaries are indexed by keys, which can be any immutable type; # strings and numbers can always be keys. # Tuples can be used as keys if they contain only strings, numbers, or tuples; # if a tuple contains any mutable object either directly or indirectly, # it cannot be used as a key. # You can't use lists as keys, since lists can be modified.# a dictionary is an unordered set of key: value pairs, with the requirement that the # keys are unique (within one dictionary). tel = {'jack': 4098, 'sape': 4139}tel['guido'] = 4127print telprint tel['jack']del tel['sape']tel['irv'] = 4127print teltel.keys()print tel.has_key('guido')print 'guido' in tel
相关内容
- Random float,randomfloat,import rando
- Change Dir,changedir,import osos.
- Get element by name,getelementbyname,from xml.dom
- Rectangle Border width,rectangleborder,from Tkinter
- Sorting Keys: for Loops,sortingloops,D = {'a': 1,
- Use file pointer to get file content,usepointer,f = open('so
- List files in the zip file,listzip,import zipfi
- String method: With a minor replacement,minorreplacement,quote = 'P
- Default parameter values,parametervalues,# positional
- List index(x),listindex,# Return the
评论关闭