English documents:
getattr
(object, name[, default])
Return the value of the named attribute of
object.
name must is a string. The If the string is the name of the one of the object ' s
Python object-oriented-Get object information type isinstance getattr setattr hasattr
I. type () function
You can directly write the basic data type.int,strAnd so on:
>>> Class Animal (object ):... Pass...>>> Type (123)>>> Type ('20140901 ')>>> Type
Python built-in function setattr () getattr ()SetAttr (Object,name,value):Role: Sets the property value of the property with name (type:string) of the object to be values, the property name can be an existing property, or it can be a new
The GetAttr () function is the core function of Python introspection, which is used in the following general context:Get Object reference GetAttrGetAttr is used to return an object property, or a method
a:
self
Python standard library: Detailed description of the use of the built-in function hasattr () getattr () setattr (), hasattrgetattrHasattr (object, name)
This function is used to determine whether the object property (name) exists. If the property
GetAttr (object, Name[,default])Gets the object's property or method, if it exists, prints the default value if it does not exist, and the default value is optional. It is important to note that if you are returning an object's method, the memory
This article turns from https://www.cnblogs.com/cenyu/p/5713686.htmlHasattr (object, name)Determines whether an object has a Name property or a name method, returns a bool value, returns true with the name attribute, or FALSE.It is important to note
Hasattr (object, name)Determines whether an object has a Name property or a name method, returns a bool value, returns true with the name attribute, or FALSE.It is important to note that name is enclosed in parentheses.>>> class Test (): ...
The "1" getattr () function is Pythonthe core function of introspection"2" Python'sIntrospection: Python can view functions or module information stored as objects in memory, as well as related operations. "3" Related functions: GetAttr (), SetAttr (
One, Hasattr (object, name)Determines whether an object has a Name property or a name method, returns a bool value, has the Name property or method returns True, otherwise returns false.>>> class Test (): ... Name= "Xiaohua" ... def run
GetAttr (object, name[, default]), valueGet A named attribute from an object; GetAttr (x, ' Y ') is equivalent to x.y.When a default argument is given, it's returned when the attribute doesn ' tExist Without it, an exception was raised in the
getattr function syntax format: GetAttr (object, name[, default) parameter is an object, object property value, object property does not exist the corresponding default value name must be a string. If name is the property of an object, the value of
Reflection:1. The module can be imported in the form of a string1.1. Single-Layer Import1 __import__ (' module name ')View Code1.2. Multi-layer Import1 __import__ (' list.text.commons'# If you don't add fromlist=true, only the list directory will
python built-in function--hasattr&setattr&getattr&delattr
Hasattr & SetAttr & GetAttr & Delattrhasattr (object,name): Used to determine whether or not a name exists in an object. SetAttr (object, name, value): This function assigns a value to an
GetAttr () is a function, while __getattr__ (), __getattribute__ () is a method of class1. GetAttr () parameter is (Object,attr_name,default value)The __getattribute__ () method of the object is called, and if there is no return value, continue
This function implements the Get property of object. Property is represented by name, which is a string of property names. The parameter default is an optional parameter that is returned when the property that gets the object does not exist.
Python standard library: built-in function getattr (object, name [, default]), pythongetattr
This function is used to obtain the attributes of the object. The attributes are represented by the name, which is the string of the attribute name. The
This function implements the property that gets the object, which is represented by name , and is the string of the property name. The parameter default is an optional parameter that returns this value when the property of the Get object does not
GetAttr (object, name[, default]), valueGet A named attribute from an object; GetAttr (x, ' Y ') is equivalent to x.y.When a default argument is given, it's returned when the attribute doesn ' tExist Without it, an exception was raised in the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.