如何自动重新加载我的输出?
How can I automatically reload my output?
我想从日期、月份和年份进行计数,我想在带有 raspberry pi 或类似内容的小屏幕上显示计数。我如何生成循环等以更新屏幕上的数字(例如每小时)?
这是我写的代码:
import time
now = time.localtime()
day=now.tm_mday
month=now.tm_mon
year=now.tm_year
hour=now.tm_hour
minute=now.tm_min
summer=now.tm_isdst
print("Tag:", day)
print("Monat:", month)
print("Jahr:", year)
if month<4:
j=year-2020
elif month==4:
if day<4:
j=year-2020
else:
j=year-2019
else:
j=year-2019
if month<4:
m=month+7
elif month==4:
if day<7:
m=month+7
elif day>=7:
m=0
else:
m=month-4
else:
m=month-4
if day<7:
t=day+24
elif day==7:
t=0
else:
t=day-7
print(j , ":" , m , ":" , t)
定时器应该从 2020 年 4 月 7 日开始工作。
这个循环工作得很好......
from datetime import datetime # for managing dates and times
import time # for sleeping
while True: # Just loop forever
time.sleep(0.0) # Set this to modify the tick rate
d = datetime.now() # Update time
print(d.strftime("%A %d. %B %Y %H:%M:%S.%f"),end="\r") # Print time
如果您对 strftime 感到困惑,请查看此处的格式占位符:https://strftime.org/
因此,我将您发送给我的代码放入了我的项目中,并且运行良好。我的下一步是将数字(年、月、日)放在 window 或类似的东西中,以在带有 raspberry pi 的屏幕上显示计数器。那么,如何在不关闭 window 的情况下打开一个显示计数器并每小时更新一次的 window?
到目前为止,这是我的代码:
import time
now = time.localtime()
hour=now.tm_hour
minute=now.tm_min
summer=now.tm_isdst
#print("Tag:", day)
#print("Monat:", month)
#print("Jahr:", year)
while True:
time.sleep(3600.0)
day=7
month=4
year=now.tm_year
if month<4:
j=year-2020
elif month==4:
if day<4:
j=year-2020
else:
j=year-2019
else:
j=year-2019
if month<4:
m=month+7
elif month==4:
if day<7:
m=month+7
elif day>=7:
m=0
else:
m=month-4
else:
m=month-4
if day<7:
t=day+24
elif day==7:
t=0
else:
t=day-7
print(j , ":" , m , ":" , t) #vllt noch h und min???
我想从日期、月份和年份进行计数,我想在带有 raspberry pi 或类似内容的小屏幕上显示计数。我如何生成循环等以更新屏幕上的数字(例如每小时)?
这是我写的代码:
import time
now = time.localtime()
day=now.tm_mday
month=now.tm_mon
year=now.tm_year
hour=now.tm_hour
minute=now.tm_min
summer=now.tm_isdst
print("Tag:", day)
print("Monat:", month)
print("Jahr:", year)
if month<4:
j=year-2020
elif month==4:
if day<4:
j=year-2020
else:
j=year-2019
else:
j=year-2019
if month<4:
m=month+7
elif month==4:
if day<7:
m=month+7
elif day>=7:
m=0
else:
m=month-4
else:
m=month-4
if day<7:
t=day+24
elif day==7:
t=0
else:
t=day-7
print(j , ":" , m , ":" , t)
定时器应该从 2020 年 4 月 7 日开始工作。
这个循环工作得很好......
from datetime import datetime # for managing dates and times
import time # for sleeping
while True: # Just loop forever
time.sleep(0.0) # Set this to modify the tick rate
d = datetime.now() # Update time
print(d.strftime("%A %d. %B %Y %H:%M:%S.%f"),end="\r") # Print time
如果您对 strftime 感到困惑,请查看此处的格式占位符:https://strftime.org/
因此,我将您发送给我的代码放入了我的项目中,并且运行良好。我的下一步是将数字(年、月、日)放在 window 或类似的东西中,以在带有 raspberry pi 的屏幕上显示计数器。那么,如何在不关闭 window 的情况下打开一个显示计数器并每小时更新一次的 window?
到目前为止,这是我的代码:
import time
now = time.localtime()
hour=now.tm_hour
minute=now.tm_min
summer=now.tm_isdst
#print("Tag:", day)
#print("Monat:", month)
#print("Jahr:", year)
while True:
time.sleep(3600.0)
day=7
month=4
year=now.tm_year
if month<4:
j=year-2020
elif month==4:
if day<4:
j=year-2020
else:
j=year-2019
else:
j=year-2019
if month<4:
m=month+7
elif month==4:
if day<7:
m=month+7
elif day>=7:
m=0
else:
m=month-4
else:
m=month-4
if day<7:
t=day+24
elif day==7:
t=0
else:
t=day-7
print(j , ":" , m , ":" , t) #vllt noch h und min???