Writing Python File at Specific Interval
denismfmcmahon at gmail.com
Thu Jul 10 01:51:01 CEST 2014
On Wed, 09 Jul 2014 07:36:49 -0700, subhabangalore wrote:
> The code (a basic crawler) would run every morning or evening, on a
> predefined time. [This part is fine].
> In the next part, I am trying to store the daily results to a new file.
So what you want to do is store each day's results in a new file, so
probably you want to create a filename that looks something like an iso
Luckily for you python has this functionality available:
Python 2.7.3 (default, Feb 27 2014, 19:58:35)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import date
>>> fn = date.today().isoformat() + ".log"
>>> print fn
Once you have a string containing your filename, you might use:
fp = open( fn, "w" )
fp.write( data )
Denis McMahon, denismfmcmahon at gmail.com
More information about the Python-list