作者demonxxx (demon)
看板Python
標題Re: [問題] 如何透過另一個py檔來run?
時間Thu Aug 2 19:20:26 2012
※ 引述《demonxxx (demon)》之銘言:
: test.py
: class test(xxx.xxx):
: def xxx(self):
: self.xxx.xxx()
: if __name__ == "__main__":
: xxx.main()
: 我單獨run test.py是可以的。
: 我想寫一個py檔去呼叫test.py來run,我該如何做?
x.py
import test
class x:
def xxx(self):
???
xxx()
???這裡我需要下什麼指令才可以透過x.py去run test.py ?
我如果使用execfile("path-to-test.py"),不會error也不會run
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.43.189.51
※ 編輯: demonxxx 來自: 114.43.189.51 (08/02 19:21)
推 retard:就 import 再 call function 08/02 21:35
→ demonxxx:妳是指我???這裡下 test.test() 這樣嗎? 08/02 22:54
→ demonxxx:ValueError: no such test method in <class test.test> 08/03 09:50
推 changyuheng:有沒有完整的 code?看不懂您的 code 為什麼應該會跑 08/03 11:55
→ demonxxx:感謝啦~ test.test(xxx.xxx) it's ok !! 08/03 13:28
推 cobrasgo:os.system()? 08/11 15:20