class Define_time:
def __init__(self):
pass
d = Define_time()
d.real_time = time.strftime('%l:%M:%S')
def capture_time():
d.real_time = time.strftime('%l:%M:%S')
return d.real_time
while True:
capture_time()
if d.real_time == '3:37:00':
time.sleep(1)
s.login(smtpUser, smtpPass)
s.sendmail(fromAdd, toAdd, header + '\n' + body)
print('Email Sent')
time.sleep(5)
else:
print(d.real_time)
2 Answers
%l if not part of standard formatting for python but assuming you are on Linux it's:
%l The hour (12-hour clock) as a decimal number (range 1 to 12);
single digits are preceded by a blank. (See also %I.)
(Calculated from tm_hour.) (TZ)
Note: "single digits are preceded by a blank".
So your string is " 3:37:00".
I suggest using %H:%M:%S instead.
Looking for this code to solve the problem:
def capture_time():
d.real_time = time.strftime('%H:%M:%S')
return d.real_time
while True:
capture_time()
if d.real_time == '15:37:00':`
if '3:37:00' == '3:37:00':