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
Post a Comment