Python string using date and time -


this bit of newbie question. i'm trying change format of filename.

currently it's in format sitename_products.xml

import time timestr = time.strftime("%y%m%d%h%m%s")  ...  def spider_opened(self, spider):     file = open('%s_products.xml' % spider.name, 'w+b')     self.files[spider] = file     self.exporter = xmlitemexporter(file)     self.exporter.start_exporting() 

how change in format sitename_datetime.xml?

this have tried:

    file = open('%s_timestr.xml' % spider.name, 'w+b')  

you can perform multiple % substitutions string.

file = open('%s_%s.xml' % (spider.name, timestr), 'w+b') 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -