__builtin __。pi中的dict方法

时间:2014-12-01 18:57:37

标签: python-2.7 built-in

我尝试了解内置 .pi文件。

阅读有关dict类的文件:

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 __init__(self):
    """ x.__init__(...) initializes x; see help(type(x)) for signature """
    return {}

  def clear(self):
    """ D.clear() -> None.  Remove all items from D. """
    return None

  def copy(self):
    """ D.copy() -> a shallow copy of D """
    return None

  def fromkeys(self, S, v=None):
    """ dict.fromkeys(S[,v]) -> New dict with keys from S and values equal to v.
    v defaults to None. """
    return {}

  def get(self, k, d=None):
    """ D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None. """
    return None
例如,

。如果我调用dict_object.get(key),我的python IDE会将我指向get方法,但是dict类中的get方法总是返回None。这是如何运作的。谢谢

0 个答案:

没有答案