小智 5
根据编辑 test2.py 的能力,有两个选项:
在test1.py文件中:
from test2 import test2class
t2c = test2class(neededArgumetGoHere)
t2c.main()
Run Code Online (Sandbox Code Playgroud)
在test2.py文件中:
class test2class:
def __init__(self, neededArgumetGoHere):
self.myNeededArgument = neededArgumetGoHere
def main(self):
# do stuff here
pass
# to run it from console like a simple script use
if __name__ == "__main__":
t2c = test2class(neededArgumetGoHere)
t2c.main()
Run Code Online (Sandbox Code Playgroud)
测试1.py
from subprocess import call
call(['path/to/python','test2.py','neededArgumetGoHere'])
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2057 次 |
| 最近记录: |