matplotlib - Python list and time -
i trying current time , store when run os command ( runs once second) can plot graph of time vs output of command.
when try store current time in list using: (timelist empty list)
timelist.append (datetime.datetime.time(datetime.datetime.now()))
i this:
[datetime.time(23, 57, 8, 86885), datetime.time(23, 57, 8, 87091), datetime.time(23, 57, 9, 90906), datetime.time(23, 57, 10, 95045), datetime.time(23, 57, 10, 95110), datetime.time(23, 57, 10, 95148), datetime.time(23, 57, 10, 95166), datetime.time(23, 57, 10, 95178)]
so in 1 second, instead of 1 list item current time, 2, or 3 items). how capture time @ instant , store in list can use pyplot plot this?
i using this, , works fine (python 3.3+):
from datetime import datetime time_list = [] time_list.append(datetime.now())
if want save or send other application without converting types can think use timestamp rather:
from datetime import datetime time_list = [] time_list.append(datetime.now().timestamp())
Comments
Post a Comment