from time import time
start = time() # time in seconds from some arbitrary date in 1970 (it's a standard)
input('hit return to get your wage!')
end = time()
elapsed = end - start # time that has passed in seconds between start and end
wage = hourly_rate * elapsed / (60 * 60) # convert from hourly
print('you earned', wage)
只有当有人按ctrl-C或类似键时,才会生成键盘中断。你知道吗
听起来你的计划是要有这样的代码:
然后有人按ctrl-C?这将与try/except一起工作。但是如果你想让某人按回车键,那么不要把事情累加起来,而是做一些数学计算:
第一个版本是有点乐观,因为它增加了每一个小时开始。第二个更准确。你知道吗
恭喜你哥哥!你知道吗
相关问题 更多 >
编程相关推荐