현재 저는 이것을 3 개의 별도 '메시지'로 분류했습니다. 그러나 나는 그것이 하나의 'msg'가 될 필요가있다.이들을 단일 'msg'변수에 결합하는 방법은 무엇입니까?
def dateDiffInSeconds(date1, date2):
timedelta = date2 - date1
return timedelta.days * 24 * 3600 + timedelta.seconds
def daysHoursMinutesSecondsFromSeconds(seconds):
minutes, seconds = divmod(seconds, 60)
hours, minutes = divmod(minutes, 60)
days, hours = divmod(hours, 24)
return (days, hours, minutes, seconds)
injustice2 = datetime.strptime('2017-05-15 23:01:00', '%Y-%m-%d %H:%M:%S')
fridaythe13th = datetime.strptime('2017-05-25 23:01:00', '%Y-%m-%d %H:%M:%S')
shadowofwar = datetime.strptime('2017-08-21 23:01:00', '%Y-%m-%d %H:%M:%S')
now = datetime.now()
msg = (
'**%d** days, **%d** hours, **%d** minutes, and **%d** seconds until the release of **Injustice 2**.'
) % daysHoursMinutesSecondsFromSeconds(dateDiffInSeconds(now, injustice2))
msg2 = (
'**%d** days, **%d** hours, **%d** minutes, and **%d** seconds until the release of **Friday the 13th: The Game**.'
) % daysHoursMinutesSecondsFromSeconds(dateDiffInSeconds(now, fridaythe13th))
msg3 = (
'**%d** days, **%d** hours, **%d** minutes, and **%d** seconds until the release of **Middle-earth: Shadow of War**.'
) % daysHoursMinutesSecondsFromSeconds(dateDiffInSeconds(now, shadowofwar))
나는 이것을 시도했지만 "TypeError : 형식 문자열에 대한 인수가 충분하지 않습니다."라는 메시지가 나타납니다. 이것이 내가 충분히 잘 이해하지 못하는 간단한 문제라는 것을 알고 있습니다. 어떤 도움을 주시면 감사하겠습니다.
msg = (
'**%d** days, **%d** hours, **%d** minutes, and **%d** seconds until the release of **Injustice 2**.'
'**%d** days, **%d** hours, **%d** minutes, and **%d** seconds until the release of **Friday the 13th: The Game**.'
'**%d** days, **%d** hours, **%d** minutes, and **%d** seconds until the release of **Middle-earth: Shadow of War**.'
) % daysHoursMinutesSecondsFromSeconds(dateDiffInSeconds(now, injustice2)), daysHoursMinutesSecondsFromSeconds(dateDiffInSeconds(now, fridaythe13th)), daysHoursMinutesSecondsFromSeconds(dateDiffInSeconds(now, shadowofwar))
길이 3. – Grimmy