Python string split -
What would be the best way to split it into Python (address, city, state, zip)
& lt; Div class = "adtxt" & gt; 7616 W. Belmont Avenue & lt; Br / & gt; Chicago, IL 60634-3225 & lt; / Div & gt;
In some cases there is a zip code
& lt; Div class = "adtxt" & gt; 7616 W Belmont Avenue & lt; Br / & gt; Chicago, IL 60634 & lt; / Div & gt;
You do not want to depend on those aspects which are hard or loose An example can be estimated from one example, some of the following should work ...:
import re s = re.compile (r '^ & lt; div. *? & Gt; ([^ & lt;] +) & lt; br. *? & Gt; ([^,] +), (\ w \ w) (\ d {5} - \ d {4}) Lt; / div & gt; $ ') mo = s .match (thestring) If there is no one: increase the value ('% r '% no match for thestring) address, city, state, zip = mo.groups ()
Comments
Post a Comment