a regual expression problem
I have a url of image, and I want to get the filename and extension of the image. How to write in python? for example, the url is http://a.b.com/aaa.jpg?version=1.1 how can I get aaa and jpg by python? -- http://mail.python.org/mailman/listinfo/python-list
How to calculate two time?
I have two string like "2007-03-27T08:54:43+08:00 " how do I get the hours between these two time(string format)? -- http://mail.python.org/mailman/listinfo/python-list
Re: How to calculate two time?
I have solved the problem. thank you On Oct 9, 7:20 pm, [EMAIL PROTECTED] wrote: > lookon> Thank you for your help.It works. However, I am using Google > lookon> App Engine and cannot import dateutil and epsilon. > > I don't know how Google App Engine works, but are you not able to install > pure Python modules? > > lookon> Are there any other ways? > > Take a look at the time.strptime function to generate a tuple, then use > > t = time.strptime(timestamp, format) > t1 = datetime.datetime(*t[0:6]) > > Note that with this solution you will have to handle the timezone offset > yourself. > > Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: How to calculate two time?
but can you tell me what format is it? in the str there is a float and I can not deal with it On Oct 9, 7:20 pm, [EMAIL PROTECTED] wrote: > lookon> Thank you for your help.It works. However, I am using Google > lookon> App Engine and cannot import dateutil and epsilon. > > I don't know how Google App Engine works, but are you not able to install > pure Python modules? > > lookon> Are there any other ways? > > Take a look at the time.strptime function to generate a tuple, then use > > t = time.strptime(timestamp, format) > t1 = datetime.datetime(*t[0:6]) > > Note that with this solution you will have to handle the timezone offset > yourself. > > Skip -- http://mail.python.org/mailman/listinfo/python-list
Re: How to calculate two time?
Thank you for your help.It works. However, I am using Google App Engine and cannot import dateutil and epsilon. Are there any other ways? On Oct 8, 10:06 pm, [EMAIL PROTECTED] wrote: > lookon> I have two string like "2007-03-27T08:54:43+08:00 " how do I get > lookon> the hours between these two time(string format)? > > Look in PyPI for dateutil, then: > > >>> import dateutil.parser > >>> t1 = dateutil.parser.parse("2007-03-27T08:54:43+08:00") > >>> t1 > datetime.datetime(2007, 3, 27, 8, 54, 43, tzinfo=tzoffset(None, 28800)) > >>> t2 = dateutil.parser.parse("2007-03-29T10:00:00+02:00") >>> t2 > datetime.datetime(2007, 3, 29, 10, 0, tzinfo=tzoffset(None, 7200)) > >>> t2 - t1 > datetime.timedelta(2, 25517) > > Skip -- http://mail.python.org/mailman/listinfo/python-list
a regular expression problem
I want to use django to dispatch url. The url is like /test/Google/6,and my patten is r'^/test/(?P\b\W+ \b)/(?P\d+)$'. It works when the string is English(like Google), but fails when the string is in foreign language. Can anyone tell me the righ regular expression? Thank you! -- http://mail.python.org/mailman/listinfo/python-list
How to detect Chinese in a string?
I have a string a(for example, a='中文Chinese'), and I want to know whether there are some Chinese in the string. Can someone tell me how to do it? Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: How to detect Chinese in a string?
Get it. Thanks Peter Otten wrote: > lookon wrote: > > > I have a string a(for example, a='中文Chinese'), and I want to know > > whether there are some Chinese in the string. > > > > Can someone tell me how to do it? Thanks! > > See > > http://mail.python.org/pipermail/python-list/2008-September/509738.html > > Instead of re.findall(...) > > you may use > > if re.search(...): > print "There are Chinese chars" > > Remember to decode the string with the proper encoding first, e. g. > > a = a.decode("utf-8") > > Peter -- http://mail.python.org/mailman/listinfo/python-list
How to install simplejson on WinXP
I am new to python and had difficulty in installing simplejson on WinXP...Could anyone help me? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: How to install simplejson on WinXP
I just installed again to see the error message. But it worked OK now. The problem was about compiling the c extension last time. Fredrik Lundh wrote: > lookon wrote: > > > I am new to python and had difficulty in installing simplejson on > > WinXP...Could anyone help me? Thanks > > what did you try, and what happened when you tried that? > > -- http://mail.python.org/mailman/listinfo/python-list