import datetime now = datetime.datetime.now() print(now.year, now.month, now.day, now.hour, now.minute, now.second) # 2015 5 6 8 53 40
Here is what the above code is Doing:
1. We import the datetime module.
2. We create a variable named now and set it equal to datetime.datetime.now().
3. We print the year, month, day, hour, minute, and second of now to the console.