xxxxxxxxxx
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
xxxxxxxxxx
from datetime import datetime
# Create a DateTime object
dt = datetime.now()
# Extract the hour from the DateTime object
hour = dt.hour
print(hour)