Summary of the relationship between classes, instances and objects in phthin

**

Summary of the relationship between classes, instances and objects in phthin

**
Before talking about their relationship, let's first understand the concept of class and instance. The concept of object
1. A class is a general term for multiple similar things, that is, a general term for a class of things. such as

```python
	#直接运行代码
print(type('666'))  # <class'str'>
print(type(6666))  # <class'int'>
print(type([6666])) #<class'list'>

After running the above code, we found that '666' belongs to the'str' string class; 6666 belongs to the'int' integer class; [6666] belongs to the'list' class.

The reason why a class is called a class is that there are countless similar but different examples under the class. For example, your iphone and my android phones belong to the mobile phone category; Yue Yunpeng and Guo Qilin both belong to the star category; and Lao Fan and Zhang Bichen next door belong to the singer category.

In Python programming arena, each class has many instances. For example, 520 and 1314 are integers; 3.1415926 and 9.85 are floating-point numbers; and'hi' and'hello' are all string types.
`
2. An instance is a concrete thing.
3. In phthon, all things are called objects, which means that both classes and instances can be objects.

-After talking about the concepts, in their words, a class is a general term for multiple similar instances, an instance is an instance of a class, and an object can be a class or an instance. In phthon, everything is an object.

**

If there is any inappropriateness, all friends are welcome to criticize and correct. . . . . . . .
I hope friends who agree to like and forward, friends who have questions can leave a message

Guess you like

Origin blog.csdn.net/qq_53283368/article/details/113975029