代码中运行一个py后关闭原文件

refresh_count = 0
while True:
    refresh_Page()#调用函数
    print(prompt_text)
    refresh_count += 1
    if prompt_text == '表名加载完全!':
        driver1.quit()
        os.system('E:\\Python相关\\test\\客票所报表2.0.py')
        break
    else:
        if refresh_count <= 20:#刷20次
            time.sleep(180)#每3分钟刷新一次
            continue
        else:
            driver1.quit()
            sendMail(yestoday_date+'客票IQ数据加载不完整')
            break
exit()

请注意第8行:os.system('E:\Python相关\test\客票所报表2.0.py')
我想一旦运行这个py后,我现在的py文件就关闭或退出,如何实现呢?

???
你是说运行其他的py文件是吧?

首先你先导入这个py文件
方法:https://blog.csdn.net/shenshenruoxi/article/details/108734220
然后再第8行调用这个py里面的函数执行

再下一行写终止程序的代码:https://blog.csdn.net/a1010256340/article/details/83029796

quit 直接结束了吧。