How to print complete TimeTuple in Python?

PythonServer Side ProgrammingProgramming

The timetuple() method of datetime.date instances returns an object of type time.struct_time. The struct_time is a named tuple object (A named tuple object has attributes that can be accessed by an index or by name). 

 example

You can print the complete time tuple by simply passing it to print.

import datetime
todaysDate = datetime.date.today()
timeTuple = todaysDate.timetuple()
print(timeTuple)

Output

This will give the output −

time.struct_time(tm_year=2017, tm_mon=12, tm_mday=28, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=362, tm_isdst=-1)
raja
Published on 05-Jan-2018 13:24:09
Advertisements