Delattr (object, name)
英文说明: Remove the property with the object name named name. The name of this function is very easy to understand Ah, and jquery in the same, but the function is not the same oh, pay attention.
Parameter: Object.
Parameter name: property name string.
Version: This function is supported in each version and is still available in Python3.
English Description: This is a relative of setattr (). The arguments is an object and a string. The string must be the name of the one of the object ' s attributes. The function deletes the named attribute, provided the object allows it. For example, delattr (x, ' Foobar ') are equivalent to Del X.foobar.
code example:
>>> class Person: ... def __init__ (self, Name, age): ... Self.name = Name ... Self.age = age...>>> Tom = person ("Tom", "a") >>> dir (Tom) [' __doc__ ', ' __init__ ', ' __module__ ', ' age ', ' n Ame ']>>> delattr (Tom, "Age") >>> dir (Tom) [' __doc__ ', ' __init__ ', ' __module__ ', ' name ']