I'll ask the question using an example code I'm stuck with. I have two questions but they sort of ask the same concept. I'm trying to print date/time using:
print(datetime.now().day, datetime.now().month, datetime.now().hour, datetime.now().minute)
QUESTION 1: But I don't want to keep retyping datetime.now() all the time. Is there a way to do this in Python?
Something like this??
print("{day} - {month} - {hour}:{minute}".format(datetiem.now())
Obviously that's wrong but you get the idea.
QUESTION 2: Or, is there a way to automate module call from a class like this:
for item in ['day', 'month', 'hour', 'minute']:
print(datetime.now().item)
Thanks.