Date using input

flebber flebber.crue at
Thu Sep 24 12:13:57 CEST 2009

Sorry to ask a simple question but I am a little confused how to
combine the input function and the date time module.

Simply at the start of the program I want to prompt the user to enter
the date, desirably in the format dd/mm/year.
However I want to make sure that python understands the time format
because first the date will form part of the name of the output file
so dd/mm/year as 1st September 2009, secondly if I have multiple
output files saved in a directory I may need to search later on the
files and contents of files by date range. So can I timestamp the

I know this is a simple question but it eludes me exactly how to do

I have the basics from

from datetime import date
date = input("type date dd/mm/year: ")

# some program blocks

#print to file(name = date) or apphend if it exists

More information about the Python-list mailing list