Fixed; not elegant, but if interested...

mike milliger milliger at ausinfo.com
Thu Jun 10 19:33:25 CEST 1999


date2= time.localtime(time.time())

year = repr(date2[0])
month= repr(date2[1])
day  = repr(date2[2])
hour = repr(date2[3])
min  = repr(date2[4])
sec  = repr(date2[5])

f = year + month + day
b = hour+ min+ sec

os.system (r"pkzip25 -add blah"+ f + r"_" + b +r".zip data_in.dat")

to get this file: blahyyyymmss_hhmmss.zip
although i am not guaranteed to get 2 spots if the integer value is less
than 10.


mike milliger wrote:

> I read the documentation in the Python Reference Library (6.3) on time
> access and conversions and chapter 8 in programming python, yet I can't
> figure out if i need ( or how to use) a tuple to format the return from
> localtime().  i get a string now (wed jun 10 1999 xx:xx:xx) but i need
> to format it to yyyymmdd_hhmmss.  Is there any switch ( %) or function
> that can be useful?  Any help is appreciated.
> --mike





More information about the Python-list mailing list