作者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)
1F:推 retard:就 import 再 call function 08/02 21:35
2F:→ demonxxx:你是指我???这里下 test.test() 这样吗? 08/02 22:54
3F:→ demonxxx:ValueError: no such test method in <class test.test> 08/03 09:50
4F:推 changyuheng:有没有完整的 code?看不懂您的 code 为什麽应该会跑 08/03 11:55
5F:→ demonxxx:感谢啦~ test.test(xxx.xxx) it's ok !! 08/03 13:28
6F:推 cobrasgo:os.system()? 08/11 15:20