rstrip accepts the set (although the argument can be any iterable, for example str in your example) of characters to delete, rather than a single line.
And by the way, the string representation of datetime.datetime not fixed, you cannot rely on it. Instead, use isoformat on date or strftime :
>>> import datetime >>> test1 = datetime.datetime(2011, 6, 10, 0, 0) >>> test1.date().isoformat() '2011-06-10' >>> test1.strftime('%Y-%m-%d') '2011-06-10'
source share