【问题标题】:Ending a program when the window is closed [duplicate]关闭窗口时结束程序[重复]
【发布时间】:2021-06-07 00:04:35
【问题描述】:

我有一个程序在用户按下我网站上的按钮时运行。当他们关闭窗口时,有没有办法结束程序?否则他们会继续收到短信。 (这是使用 Flask 的 python 和 html)

【问题讨论】:

  • 当你说运行一个程序时,你的意思是在javascript中他们点击一个按钮并向服务器发送一个信号来启动一个程序吗?您想在他们离开网站后停止该程序吗?

标签: python html flask


【解决方案1】:

这会对你有所帮助 -

import sys

sys.exit() # Add this code when they close the website window

【讨论】:

  • 你在哪里添加这个?我怎么知道他们何时关闭网站窗口?
  • 我以为你知道这一点 - [Django 网站]。把上面的函数放在这个后面(stackoverflow.com/questions/64937691/…)
猜你喜欢
  • 2019-08-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-04-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多