finding contents from string

D

danin

Hi all,
I am looking for particular solution. I am having one string
say:
string- "http://maps.google.co.in/maps/ms?
hl=en&ie=UTF8&msa=0&msid=106178526636832397420.00047fb46fa8d02481f09&ll=20.730428,86.456909&spn=2.178194,3.526611&z=8
"
and from this string i need to extract value
-20.730428,86.456909. These value are dynamic so i cant use filter. So
can anyone please tell me about how to do this.
 
A

Arnaud Delobelle

danin said:
Hi all,
I am looking for particular solution. I am having one string
say:
string- "http://maps.google.co.in/maps/ms?
hl=en&ie=UTF8&msa=0&msid=106178526636832397420.00047fb46fa8d02481f09&ll=20.730428,86.456909&spn=2.178194,3.526611&z=8
"
and from this string i need to extract value
-20.730428,86.456909. These value are dynamic so i cant use filter. So
can anyone please tell me about how to do this.

In Python 2.5:
{'bar': ['42'], 'spam': ['eggs']}

In Python >= 2.6, parse_qs lives in the urlparse module as well.
 
P

Peter Otten

danin said:
Hi all,
I am looking for particular solution. I am having one string
say:
string- "http://maps.google.co.in/maps/ms?
hl=en&ie=UTF8&msa=0&msid=106178526636832397420.00047fb46fa8d02481f09&ll=20.730428,86.456909&spn=2.178194,3.526611&z=8
"
and from this string i need to extract value
-20.730428,86.456909.

Where does the "-" come from?
These value are dynamic so i cant use filter.

I don't understand.
So can anyone please tell me about how to do this.
from urlparse import urlparse, parse_qs
parse_qs(urlparse(string).query)["ll"][0]
'20.730428,86.456909'

Peter
 
L

Lars Behrens

danin said:
can anyone please tell me about how to do this.

Now come on, you have to give a *bit* more information. What have you done
so far? What did you plan? What are the rules for finding the string?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,176
Messages
2,570,947
Members
47,501
Latest member
Ledmyplace

Latest Threads

Top