# 定义时间显示
self.timer = QtCore.QTimer(self)
self.timer.timeout.connect(self.act_displayTM)#绑定响应函数
self.timer.setInterval(1000)#设置时间间隔
self.timer.start()
# 定时响应事件对应逻辑
def act_displayTM(self):
s_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
self.ui.label_Date.setText(s_time)
return
可以不用一直保持此程序运行啊,Linux的话可以用低消耗的crontab 来自定义时间执行此python命令即可。
提供个思路,可以使用python的apscheduler库。
你是ython3还是Python2?它们运行暂停的方法也有所不同,以python3为例:1、input()
这种方法不用包含模块,因此这也是最常用的一种暂停手段。
Python2中的raw_input()和input()语句在Python3中已经被合并到input()中。
2、os.system("pause")
这种方法需要包含os模块(import os),在windows下IDLE运行会弹出cmd命令行,
进行暂停操作,直接运行.py文件会直接在命令行中暂停。
3、time.sleep("second")
这种方法需要包含time模块(import time),second是自定义的时间长短,根据实际情况,