while loop - Can I damage the system by running time.sleep() with this newbie code in Python? -
I'm sure there is a better way to do this, but I'm a newbie so find out that I did the only way. The thing is, I have a script that updates a text file with the latest posts from RSS feeds (I got some help from you to know this). But I want to automate this script, so I created it:
import time import os seconds = 3600 kjor = 'python vg.py' time.sleep (seconds) os.system ( Kjor) Time.sleep (seconds) os.system (kjor) time.sleep (seconds) os.system (kjor)
I continued with those 24x down copy I know That could possibly be better with some loop (while?), But I'm afraid that I do not have much knowledge in that area.
My question, though, is as follows: If the system is damaged in any way, should I give it for longer periods of time?
Your question to answer, no, it will not hurt anything while time is over. Sleeping, the program will take very little processing power and the rest of the system can run normally.
Now, for your looping problem, if you want the code to turn on forever (or unless you stop the program) you want the code to be
< Code> While it is true: os.system (kjor) time.sleep (seconds)
This is really, and infinite loop, but in this case (possibly) what you want .
If you are attached to a particular number of iterations, then for the loop in the xrange (240)
look for Sukyang (duplicated) like the look Do something: os.system (kjor) time.sleep (seconds)
Finally, if you are on a Unix platform (such as Linux or Mac), you should keep an eye on the cron Because it is designed to run recurring programs to run and special time period. You can set it to run your script every minute and it will happily until the end of time (or you remove it, whichever comes first).
Comments
Post a Comment