Object-oriented (OOP) concepts
Process-oriented: Early programming concepts, similar to functions, but only executed, without return values, encapsulating functional independent code into functions, and finally sequentially invoking different functions
Functional programming: Not only to execute, but also to return results
Object-oriented: Object-oriented is a larger package that encapsulates multiple methods in an object according to responsibilities, sequentially allowing different objects to invoke different methods
Classes and objects
Classes and objects are the two core concepts of object-oriented programming
A class is a group of things that have the same characteristics or behaviors, which are abstract, cannot be used directly, are called attributes, and behaviors are called methods.
Class is the equivalent of a template that is responsible for creating objects
An object is a concrete existence that is created by a class, can be used directly, and objects created by what class have properties and methods defined in that class.
In program development, there are classes and objects
Define the class first:
classStudent (object):def __init__(self, name, age, Sex): Self.name=name Self.age=Age Self.sex=SexdefStudent_name (self):return 'my name is {}'. Format (self.name)defStudent_sge (self):return 'my age is {}'. Format (self.age)defStudent_sex (self):return 'I am a {}'. Format (Self.sex)
Recreate the object: The Created object has the properties and methods of the class
New_student = Student ('jia'' Boy')print( New_student.student_name ())
New1_student = Student ('jia'boy')
Print (New1_student.student_name ())
Python Object-oriented summary