Home > other >  Python class
Python class

Time:09-27

The class Student: def __init__ (self, name) : the self. The name=name print (" my name is % s "% self. The name) stu=Student (" XR")

Why can't directly use the name, again with a self. The name=name such assignment,

CodePudding user response:

The
refer to the original poster qq_45787858 response:
class Student: def __init__ (self, name) : the self. The name=name print (" my name is % s "% self. The name) stu=Student (" XR")

Why can't directly use the name, but also again with the self. The name=name such assignment,

Class need to be initialized in the class definition, the public variables in the class you need to use the self. To say this is a class variables, not just of a local variable in a method

CodePudding user response:

Class initialization to actual parameters passed to the class attribute

CodePudding user response:

Self. The said internal members or methods
  • Related