0

Im trying to convert a str to a date object using the python-dateutil library

from dateutil.parser import *

datetime_object = parse('Fri Feb 14 19:39:51 +0000 2020')
pprint("DATETIME", datetime_object )

However i get the following error:

AttributeError: 'datetime.datetime' object has no attribute 'write'

Kay
  • 17,906
  • 63
  • 162
  • 270

1 Answers1

3

pprint documentation states that the arguments must have the write method implemented. datetime does not. I expect that your easiest path to a solution is to use any of the available str conversions in datetime, such as the various format specifications.

Prune
  • 76,765
  • 14
  • 60
  • 81