看板 Python 關於我們 聯絡資訊
test.py class test(xxx.xxx): def xxx(self): self.xxx.xxx() if __name__ == "__main__": xxx.main() 我單獨run test.py是可以的。 我想寫一個py檔去呼叫test.py來run,我該如何做? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.32.231.88
darkgerm:execfile('test.py') 08/01 16:44
demonxxx:單獨使用這行是可以的,但是我如果加在def裡就沒反應? 08/01 16:57
demonxxx:因為我另一個py檔有寫def x(): 然後在x() 執行 08/01 16:58
weslychu:import test 08/03 00:13
weslychu:test.test(xxx.xxx) 08/03 00:14
demonxxx:TypeError: getattr():attribute name must be string 08/03 10:01