Python After 5:00pm
When a function runs I need it to check the current system time and if its past 5:00pm to do something.
current_time = datetime.datetime.now()
if current_time开发者_如何学Go > {code to represent 17:00 hours}:
do stuff
Edit for clarification: Orders are being sent into my software which handles the picking/packing of orders in a distribution center. If the order is sent into the system after 5:00 then that order needs to get flagged so that it isn't "picked" until the following day. So the function needs to be run as orders are "imported"
if datetime.datetime.now().hour >= 17:
pass
Sure, it's easy:
>>> import datetime
>>> datetime.datetime.now().time()
datetime.time(10, 36, 5, 572343)
>>> datetime.datetime.now().time() >= datetime.time(17,0,0)
False
>>> datetime.datetime.now().time() >= datetime.time(8,0,0)
True
精彩评论