class Superman: def __init__(self,name): self.name=name self.gender=1 self.signal=1 self.illness=False def nine_negative_kungfu(self): return 'ya!you have to die!' zhangsan=Superman('zhangsan') print("the superman name is:",zhangsan.name) print("superman is(0-female,1-male)",zhangsan.gender) result=zhangsan.nine_negative_kungfu() print("if superman plays nine negative kungfu,the result is:") print(result)
错误:
Traceback (most recent call last):
File "c8.py", line 1, in <module>
class Superman:
File "c8.py", line 9, in Superman
zhangsan=Superman('zhangsan')
NameError: name 'Superman' is not defined
为什么会有这个错误,我Superman定义了啊
错误:
Traceback (most recent call last):
File "c8.py", line 1, in <module>
class Superman:
File "c8.py", line 9, in Superman
zhangsan=Superman('zhangsan')
NameError: name 'Superman' is not defined
为什么会有这个错误,我Superman定义了啊