from plyer import notification
from tkinter import *
import time
def print_leran_time():
"""每隔一天来打印学习python的时间"""
x = 43
while True:
time.sleep(1)
x += 1
if x == 43:
while True:
time.sleep(1)
notification.notify(
title="你已经学习python天数:",
message=str(43),
app_icon="qq.ico",
timeout=60,
)
elif x >= 43:
while True:
time.sleep(1)
notification.notify(
title="你已经学习python天数:",
message=str(x),
app_icon="qq.ico",
timeout=60,
)
print_leran_time()
rook=Tk()
root.withdraw()
root.mainloop()
想要做一个自动后台运行的窗口督促自己学习的,但是发现该程序编译没问题,执行却会有问题。
x = 43
while True:
time.sleep(1)
x += 1 关键就在于这一段,这段不用while循环就会正常输出,但是用了while循环,x值就会变成空白,就会输出空白。
请问一下有什么办法解决吗?