我無法獲得兩個類互動。下面是我在哪裏導入文件youtest.py第一類的代碼:讓兩個類互動
from youtest import MyTest
class RunIt(object):
def __init__(self):
self.__class__ = MyTest
r = RunIt()
r.iffit()
我想通過這個類來運行類MyTest的(下面的代碼):當我運行這個
from sys import exit
class MyTest(object):
def death(self):
exit
def iffit(self):
oh_no = raw_input(">")
print "What is your name?"
if oh_no == "john":
print "welcome john"
else:
print "game over"
return 'death'
我得到如下:
文件「youtest.py」 19行 回報「死」 語法錯誤:外功能「迴歸」
希望這個問題很清楚,謝謝你的幫助。
當我在這裏查看所有問題後,我強烈建議閱讀[教程](http://docs.python.org/tutorial)。 – pillmuncher
就可以了。 thnx多 –