lsyf8 发表于 2018-8-15 10:23:41

python内置函数3-delattr()

  Help on built-in function delattr in module __builtin__:
  delattr(...)
  delattr(object, name)
  Delete a named attribute on an object; delattr(x, 'y') is equivalent to
  ``del x.y''.
  delattr(object, name)

  This is a>  class dict(**kwarg)
  class dict(mapping, **kwarg)
  class dict(iterable, **kwarg)

  Create a new dictionary. The dict object is the dictionary>
  For other containers see the built-in list, set, and tuple>  中文说明:删除object对象名为name的属性。
  参数object:对象。
  参数name:属性名称字符串。

  >>>>  ...   def __init__(self, name, age):
  ...             self.name = name
  ...             self.age = age
  ...
  >>> tom=Person("Tom", 35)
  >>> dir(tom)
  ['__doc__', '__init__', '__module__', 'age', 'name']
  >>> delattr(tom, "age")
  >>> dir(tom)
  ['__doc__', '__init__', '__module__', 'name']
页: [1]
查看完整版本: python内置函数3-delattr()