Date using input

flebber flebber.crue at gmail.com
Thu Sep 24 06:13:57 EDT 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
file?

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

I have the basics from http://docs.python.org/library/datetime.html

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

# some program blocks

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




More information about the Python-list mailing list