本帖最后由 宝塔用户_lspckw 于 2022-7-8 10:01 编辑
python 项目管理器2.0 同遇到这个问题,会在短时间内运行文件两次,目前自己写了一个switch,保证每次只有效启动一个程序
- import main
- def switch():
- f = open('status.txt', 'r+')
- status = list(f.read())[-1]
- if status == '1':
- print('开')
- f.write('0')
- f.close()
- # 主程序
- main.main()
- elif status == '0':
- print('关')
- f.write('1')
- f.close()
- if __name__ == '__main__':
- switch()
复制代码 |