2

when one prints the following:

import datetime
data = (datetime.datetime.now(), '%.3f' % float(8/9))
print(data)

he/she begets:

(datetime.datetime(2018, 10, 16, 23, 58, 19, 314376), '0.889')

However, often one would like python to write:

2018-10-16 23:58:19, 0.889

There are of course many fine ways to wood pack here and there, but which is the way of the python?

PS This is not a question about ways to print a datetime instance as a readable string (there are plenty and easily accessible answers on SO). This question additionally asks to remove the quotation marks around the two strings in data, both of which emerge in different ways when printing a tuple. There are also many easily accessible answers on ways to do this. The question is how to combine these things in the most readable/pythonic way.

Stendert
  • 97
  • 7
  • See also [How do I turn a python datetime into a string, with readable format date?](https://stackoverflow.com/questions/2158347/how-do-i-turn-a-python-datetime-into-a-string-with-readable-format-date) – pault Oct 16 '18 at 22:27

0 Answers0