如何计算if语句中的秒数?蟒蛇

时间:2019-07-24 19:53:43

标签: python

早上好,只要if语句有效,我将尝试以秒为单位,从0到n秒执行计数。请参见下面的示例,我正在尝试确定点(x,y)在监视区域内显示多长时间。

point_x = int(left_2 + (width_2-left_2)/2)
point_y = int(top_2 + (height_2-top_2)/2)
if(monitor_left < point_x < monitor_left + monitor_width and monitor_top < point_y < monitor_top + monitor_height):
    #do counting per seconds here
else:
     pass

我试图使用datetime计算如下代码的简单方法。如果该点永远不会离开该区域(我永远也无法获得end_sec值),那么它会无休止地计数。

total_sec = end_sec - start_sec

我也试图避免编写迭代,因为在几轮迭代语句中都提供了point(x,y)。因此,我能够立即检查每个最新的point_x和point_y。感谢您的时间和精力,谢谢。

0 个答案:

没有答案