0
0 комментариев
import re, datetime, calendar
 date = input("Please enter a date in this format - dd/mm/yyyy: ")
 #Using dd/mm/yyyy format for this project.
while True:
    try:
        # Defined a regular expression to check date and year from the years of 1000 to 2999.
        x = re.search("^([0-3][0-9])(/)([0-1][0-9])(/)([1-2][0-9][0-9][0-9])$", date)
        x.group()
         # Import day, month and year
        day = date[0:2]
        month = date[3:5]
        year = date[6:10]
         # print(day + month + year)
         dt = datetime.date(int(year), int(month), int(day))
        # print(dt)
        print(dt.strftime('This date was entered: %B %d, %Y'))
         break
         # log exceptions to be identified in the console
    except AttributeError:
        print("This is an invalid date format, please enter a valid date format - dd/mm/yyyy")
        date = input("Please enter a date in this format - dd/mm/yyyy: ")
     except ValueError:
        print("This is an invalid date combination, please make sure the date is correct.")
        date = input("Please enter a date in this format - dd/mm/yyyy: ")

Ребята,
Мне нужно что программа работала без функции Датетиме и календарь.

Наверное как-то с листами. Не знаю как…

Asked question
Добавить комментарий