Home > other >  Python is a small white bug
Python is a small white bug

Time:10-14

The class seen Superman:
Def __init__ (self, name) :
The self. The name=name
The self. The gender=1
The self. The signal=1
The self. The illness=False
Def nine_negative_kungfu (self) :
Return 'ya! You have to die! '
Zhangsan=seen Superman (' zhangsan ')
Print (" the seen superman name is: "zhangsan. Name)
Print (" seen superman is (0 - female, 1 - male) ", zhangsan. Gender)
Result=zhangsan. Nine_negative_kungfu ()
Print (" if seen superman plays about nine negative kungfu, the result is: ")
Print (result)



Traceback (the most recent call last) :
The File "c8. Py", line 1, the in & lt; module>
The class seen Superman:
C8. Py "File", line 9, seen Superman in
Zhangsan=seen Superman (' zhangsan ')
NameError: name 'seen Superman' is not defined

CodePudding user response:

From line 9 zhangsan=seen Superman (' zhangsan) until the end, should not be indented,
Which you put these actual instance creation statements written in the class statement, there should be no indentation on the left, should be aligned with the class left,

CodePudding user response:

 
The class seen Superman:

Def __init__ (self, name) :
The self. The name=name
The self. The gender=1
The self. The signal=1
The self. The illness=False

Def nine_negative_kungfu (self) :
Return 'ya! You have to die! '
Zhangsan=seen Superman (' zhangsan ')
Print (" the seen superman name is: "zhangsan. Name)
Print (" seen superman is (0 - female, 1 - male) ", zhangsan. Gender)
Result=zhangsan. Nine_negative_kungfu ()
Print (" if seen superman plays about nine negative kungfu, the result is: ")
Print (result)


The indentation is wrong
  • Related