Hi Tutor,

with this code i am getting actual date from internet. I need correct date, because i am not sure this set on computer is right.


import requests, time

try:
    OnLineDate = requests.get("http://just-the-time.appspot.com";).text[:10]
    OffLineDate = time.strftime("%Y-%m-%d")

    if OnLineDate == OffLineDate:

        do_something

    else:

        do_something_else


except requests.ConnectionError:
    print("Can not connect.")


But this code is run once. And i am stuck. Tries with while loop doesnt took any advance. I was thinking about something like after method used in tkinter, but still i cant figure out how do this. Can You guide me, how check connection to internet to check for every lets say 30 seconds until success?


Best regards

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to