Re: [問題] 如何透過另一個py檔來run?

看板Python作者 (demon)時間13年前 (2012/08/02 19:20), 編輯推噓3(303)
留言6則, 4人參與, 最新討論串2/2 (看更多)
※ 引述《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)

08/02 21:35, , 1F
就 import 再 call function
08/02 21:35, 1F

08/02 22:54, , 2F
妳是指我???這裡下 test.test() 這樣嗎?
08/02 22:54, 2F

08/03 09:50, , 3F
ValueError: no such test method in <class test.test>
08/03 09:50, 3F

08/03 11:55, , 4F
有沒有完整的 code?看不懂您的 code 為什麼應該會跑
08/03 11:55, 4F

08/03 13:28, , 5F
感謝啦~ test.test(xxx.xxx) it's ok !!
08/03 13:28, 5F

08/11 15:20, , 6F
os.system()?
08/11 15:20, 6F
文章代碼(AID): #1G6c9yZr (Python)
討論串 (同標題文章)
文章代碼(AID): #1G6c9yZr (Python)