Re: sscanf needed

2005-04-17 Thread Lee Harr
On 2005-04-17, Andrew E <[EMAIL PROTECTED]> wrote: > Uwe Mayer wrote: >> Hi, >> >> I've got a ISO 8601 formatted date-time string which I need to read into a >> datetime object. >> Is there a shorter way than using regular expressions? Is there a sscanf >> function as in C? > > in addition to the

Re: sscanf needed

2005-04-17 Thread Andrew E
Uwe Mayer wrote: > Hi, > > I've got a ISO 8601 formatted date-time string which I need to read into a > datetime object. > Is there a shorter way than using regular expressions? Is there a sscanf > function as in C? in addition to the other comments... I like re, because it gives me the most con

Re: sscanf needed

2005-04-17 Thread Kent Johnson
Uwe Mayer wrote: Hi, I've got a ISO 8601 formatted date-time string which I need to read into a datetime object. Something like this (adjust the format to suit): import datetime, time dt = datetime.datetime(*time.strptime(data, "%Y-%m-%d %H:%M:%S")[:6]) Kent -- http://mail.python.org/mailman/listin

Re: sscanf needed

2005-04-17 Thread Leif B. Kristensen
Uwe Mayer skrev: > Hi, > > I've got a ISO 8601 formatted date-time string which I need to read > into a datetime object. Look up time.strptime, it does exactly what you want. -- Leif Biberg Kristensen http://solumslekt.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: sscanf needed

2005-04-17 Thread Fredrik Lundh
Uwe Mayer wrote: I've got a ISO 8601 formatted date-time string which I need to read into a datetime object. import time help(time.strptime) Help on built-in function strptime in module time: strptime(...) strptime(string, format) -> struct_time Parse a string to a time tuple according to a

sscanf needed

2005-04-17 Thread Uwe Mayer
Hi, I've got a ISO 8601 formatted date-time string which I need to read into a datetime object. Is there a shorter way than using regular expressions? Is there a sscanf function as in C? Thanks, Uwe -- http://mail.python.org/mailman/listinfo/python-list