我可以在Python中每1分钟将列表中每个项目的价值增加1个吗?
我想通过不断在计算机中检查当地时间来做到这一点。是否有一种方法可以通过不检查本地机器的时间来做到这一点? 我还想编程在本地计算机上的特定时间内不执行某些语句。假设它不会在下午5点至7点之间执行IF语句。 请感谢如果有人在这个话题上提供帮助。
I would like to do it by constantly checking local time in my computer. Is there also a way to do it by NOT checking with time of local machine?
I want to also program not execute certain statements during specific times on my local machine. Let's say it does not execute the if statement between 5 and 7 pm.
I would appreciate if someone helped in this topic, please.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设我有一个列表
lst
,其中我想将数字从0到10,每分钟一次,我可以做到这一点。现在假设在上面的示例中,如果当前时间在下午5点至晚上7点之间,则不想将数字附加到列表中。
dateTime.dateTime.now()
为您提供当前的日期。由此,您可以使用小时
属性获取当前小时,但小时为24小时格式。这两个只是任意示例,但可以帮助您了解如何将时间编码到Python中。
Suppose I have a list
lst
in which I want to append numbers from 0 to 10, once per minute I can do this.Now suppose in the example above, you don't want to append the numbers to the list if the current time is between 5 pm and 7 pm use this.
datetime.datetime.now()
gets you the current datetime. From this, you can usehour
attribute to get the current hour but the hour is in 24hr format.These two are just arbitrary examples but would help you understand how you can code time into Python.