我正在使用以下代码无缝地计算我的工作时间。但是现在在安装Python 3之后,我无法获得ctypes消息框打印时间,而是只显示标题中的D和消息框中的D。
我是Python的新手,请帮我格式化这段代码,让我在Python 3.6中运行它
下面是代码
import time
import ctypes
def timer(hours): #Also i get indentation here when i see in PyCharm
seconds = hours * 3600
start = time.time()
elapsed = 0
while elapsed < seconds:
# Do something once every minute.
time.sleep(0.0010)
elapsed = time.time() - start
elapsed = elapsed/3600
float(elapsed)
ctypes.windll.user32.MessageBoxA(0,"Done " +'%.2f' %(elapsed) + " Hrs",
"Done", 0)
timer(8.9) #I usually run this with for 8h 55m to alert me 5 minutes before
9 hour