如果你想要测试1。py将保持可执行,其功能与调用内部服务时相同。py,然后做一些类似的事情:
测试1。py
def main(): print "I am a test" print "see! I do nothing productive." if __name__ == "__main__": main()
服务py
import test1 # lots of stuff here test1.main() # do whatever is in test1.py