|
#!/user/bin/evn python
# -*- coding:utf-8 -*-
userinfo = {
1:'alex',
'age':19,
3:'tony'
}
print userinfo
# class dict(object):
# """
# dict() -> new empty dictionary
# dict(mapping) -> new dictionary initialized from a mapping object's
# (key, value) pairs
# dict(iterable) -> new dictionary initialized as if via:
# d = {}
# for k, v in iterable:
# d[k] = v
# dict(**kwargs) -> new dictionary initialized with the name=value pairs
# in the keyword argument list. For example: dict(one=1, two=2)
# 清除出所健值对
# def clear(self): # real signature unknown; restored from __doc__
# """ D.clear() -> None. Remove all items from D. """
# pass
#
# userinfo.clear()
# print userinfo
# def copy(self): # real signature unknown; restored from __doc__
# 复制,类似于赋值运算符
# """ D.copy() -> a shallow copy of D """
# pass
#
# userinfo2 = userinfo.copy()
# print userinfo2
# @staticmethod # known case
# def fromkeys(S, v=None): # real signature unknown; restored from __doc__
# """
# 根据所给可迭代的量,将其他为健,将v作为值新生成一个dict,如果v没给,默认为None
# dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v.
# v defaults to None.
# """
# pass
# userinfo2 = userinfo.fromkeys(['age','tall','heavy'])
# print userinfo2
# 结果:{'heavy': None, 'tall': None, 'age': None}
# def get(self, k, d=None): # real signature unknown; restored from __doc__
# 根据键,获取值
# """ D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None. """
# pass
# print userinfo.get(1)
# 结果:alex
# def has_key(self, k): # real signature unknown; restored from __doc__
# 判断dict中是否有某个键
# """ D.has_key(k) -> True if D has a key k, else False """
# return False
#print userinfo.has_key(1)
# 结果:True
# def items(self): # real signature unknown; restored from __doc__
# """ D.items() -> list of D's (key, value) pairs, as 2-tuples """
# return []
#print userinfo.items()
# 结果[(1, 'alex'), ('age', 19), (3, 'tony')]
# for k,v in userinfo.items():
# print str(k) +':'+str(v)
# 结果:
# 1:alex
# age:19
# 3:tony
# def iteritems(self): # real signature unknown; restored from __doc__
# """ D.iteritems() -> an iterator over the (key, value) items of D """
# pass
# for k,v in userinfo.iteritems():
# print str(k) +':'+str(v)
# 结果:
# 1:alex
# age:19
# 3:tony
# def iterkeys(self): # real signature unknown; restored from __doc__
# """ D.iterkeys() -> an iterator over the keys of D """
# pass
# for k in userinfo.iterkeys():
# print k
# 结果:
# 1
# age
# 3
# def itervalues(self): # real signature unknown; restored from __doc__
# """ D.itervalues() -> an iterator over the values of D """
# pass
# for v in userinfo.itervalues():
# print v
# 结果:
# alex
# 19
# tony
# def keys(self): # real signature unknown; restored from __doc__
# 返回dict所有键的list
# """ D.keys() -> list of D's keys """
# return []
# print userinfo.keys()
# 结果:[1, 'age', 3]
# def pop(self, k, d=None): # real signature unknown; restored from __doc__
# 根据所给的健值,来移除某个键值对,如果所给键值不对或为空,则会报错
# D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
# If key is not found, d is returned if given, otherwise KeyError is raised
# """
# pass
# userinfo.pop('age')
# print userinfo
# 结果:{1: 'alex', 3: 'tony'}
# def popitem(self): # real signature unknown; restored from __doc__
# 每次移除一个键值对,从第个键值对开始移除,如果dict为空,则会报错
# D.popitem() -> (k, v), remove and return some (key, value) pair as a
# 2-tuple; but raise KeyError if D is empty.
# """
# pass
# userinfo.popitem()
# print userinfo
# 结果:{'age': 19, 3: 'tony'}
# def setdefault(self, k, d=None): # real signature unknown; restored from __doc__
# 所给键如果存在于dict中,则原来dict中的键所对应的值不变,如果不存在,则dict上新增一个键值对,如果所给值为空,则默认为None
# """ D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D """
# pass
#
# userinfo.setdefault('name',20)
# print userinfo
# 结果:{1: 'alex', 'age': 19, 3: 'tony', 'name': 20}
# def update(self, E=None, **F): # known special case of dict.update
# """
# D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
# If E present and has a .keys() method, does: for k in E: D[k] = E[k]
# If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
# In either case, this is followed by: for k in F: D[k] = F[k]
# """
# pass
#
# def values(self): # real signature unknown; restored from __doc__
# 返回dict值的list
# """ D.values() -> list of D's values """
# return []
#
# def viewitems(self): # real signature unknown; restored from __doc__
# """ D.viewitems() -> a set-like object providing a view on D's items """
# pass
#
# def viewkeys(self): # real signature unknown; restored from __doc__
# """ D.viewkeys() -> a set-like object providing a view on D's keys """
# pass
#
# def viewvalues(self): # real signature unknown; restored from __doc__
# """ D.viewvalues() -> an object providing a view on D's values """
# pass
#
# def __cmp__(self, y): # real signature unknown; restored from __doc__
# """ x.__cmp__(y) <==> cmp(x,y) """
# pass
#
# def __contains__(self, k): # real signature unknown; restored from __doc__
# """ D.__contains__(k) -> True if D has a key k, else False """
# return False
#
# def __delitem__(self, y): # real signature unknown; restored from __doc__
# """ x.__delitem__(y) <==> del x[y] """
# pass
#
# def __eq__(self, y): # real signature unknown; restored from __doc__
# """ x.__eq__(y) <==> x==y """
# pass
#
# def __getattribute__(self, name): # real signature unknown; restored from __doc__
# """ x.__getattribute__('name') <==> x.name """
# pass
#
# def __getitem__(self, y): # real signature unknown; restored from __doc__
# """ x.__getitem__(y) <==> x[y] """
# pass
#
# def __ge__(self, y): # real signature unknown; restored from __doc__
# """ x.__ge__(y) <==> x>=y """
# pass
#
# def __gt__(self, y): # real signature unknown; restored from __doc__
# """ x.__gt__(y) <==> x>y """
# pass
#
# def __init__(self, seq=None, **kwargs): # known special case of dict.__init__
# """
# dict() -> new empty dictionary
# dict(mapping) -> new dictionary initialized from a mapping object's
# (key, value) pairs
# dict(iterable) -> new dictionary initialized as if via:
# d = {}
# for k, v in iterable:
# d[k] = v
# dict(**kwargs) -> new dictionary initialized with the name=value pairs
# in the keyword argument list. For example: dict(one=1, two=2)
# # (copied from class doc)
# """
# pass
#
# def __iter__(self): # real signature unknown; restored from __doc__
# """ x.__iter__() <==> iter(x) """
# pass
#
# def __len__(self): # real signature unknown; restored from __doc__
# """ x.__len__() <==> len(x) """
# pass
#
# def __le__(self, y): # real signature unknown; restored from __doc__
# """ x.__le__(y) <==> x<=y """
# pass
#
# def __lt__(self, y): # real signature unknown; restored from __doc__
# """ x.__lt__(y) <==> x<y """
# pass
#
# @staticmethod # known case of __new__
# def __new__(S, *more): # real signature unknown; restored from __doc__
# """ T.__new__(S, ...) -> a new object with type S, a subtype of T """
# pass
#
# def __ne__(self, y): # real signature unknown; restored from __doc__
# """ x.__ne__(y) <==> x!=y """
# pass
#
# def __repr__(self): # real signature unknown; restored from __doc__
# """ x.__repr__() <==> repr(x) """
# pass
#
# def __setitem__(self, i, y): # real signature unknown; restored from __doc__
# """ x.__setitem__(i, y) <==> x=y """
# pass
#
# def __sizeof__(self): # real signature unknown; restored from __doc__
# """ D.__sizeof__() -> size of D in memory, in bytes """
# pass
#
# __hash__ = None |
|