无法import自己定义的类

Final_fantasy 发布于 2016/09/22 21:57
阅读 166
收藏 0
#Death.py
from random import randint 
class Death(object): 
 def __init__(self): 
 self.quips = [ "You died. You kinda suck at this.", "Your mom would be proud. If she were smarter.", "Such a luser.", "I have a small puppy that's better at this."  
 def death(self): 
 print (self.quips[randint(0,len(self.quips)-1)]) exit(1)

#game.py

form Death import death   #这里显示death未定义是什么原因啊?

death()

加载中
0
DLstudio
DLstudio
death是Death的方法  当然要先引入Death
返回顶部
顶部