Error in date format in python

0

I have a function in python that is responsible for recognizing the date of a text file that reads, the date format to read is this for example: May 28 00:00 , I have changed the orders according to python but it gives me an error :

TypeError: not all arguments converted during string formatting

and the line of the error is as follows:

date_time="%s %s %s"%(self.year,file['month'],file['day'],file['time'])
registro['datetime'] = datetime.strptime(date_time, "%b %d %H:%M") 

I will appreciate your help.

elif self.central in(410,411,401,402):
            date_time="%s %s %s"%(self.year,file['month'],file['day'],file['time'])   # <---
            registro['datetime'] = datetime.strptime(date_time, "%b %d %H:%M")  # <---
            registro['filename']=file['filename']
            registro['name_processed']=file['name']
            registro['correlative']=int(file['id'])
            registro['bytes']=int(file['bytes'].replace(",",""))
        else:
            date_time="%s %s %s %s"%(self.year,file['month'],file['day'],file['time'])
            registro['datetime'] =datetime.strptime(date_time,"%Y %b %d %H:%M")
            registro['filename']=file['filename']
            registro['name_processed']=file['name']
            registro['correlative']=int(file['id'])
            registro['bytes']=int(file['bytes'].replace(",",""))
        return registro
    
asked by Grindor 29.05.2018 в 19:05
source

0 answers