while循环下的time.sleep问题

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值就会变成空白,就会输出空白。
请问一下有什么办法解决吗?

img

img

经过最后想法以后,成果如上图,没有结束死循环,让他一直运行。

你这是死循环了呀,while true要加结束条件的,跳出循环

你不是要每隔一天才提醒吗??那为什么sleep那里才设置了1秒??按照你的意思,是不是要休息一天?

from plyer import notification
from tkinter import *
import time


def print_learn_time():
    """每隔一天来打印学习python的时间"""
    x = 43
    while True:
        notification.notify(
            title="你已经学习python天数:",
            message=str(x),
            app_icon="qq.ico",
            timeout=60,
        )
        time.sleep(24 * 60 * 60)
        x += 1


print_learn_time()
root = Tk()
root.withdraw()
root.mainloop()