python - How can I search a string for multiple characters? -
i trying extract info page lot of spaces in it, pretty want search letter , position, not 1 letter. how can accomplished?
edit: want search website http://www.aviationweather.gov/static/adds/metars/stations.txt user inputted city, anchorage. program search anchorage. want grab next 4 letters, way txt formatted number of spaces between city , 4 letter code different each town.
you can use
listed = text.split()
to separate text on whitespaces. have list consisting of characters.
citypos = listed.index("anchorage") code = listed[citypos+1][:4]
to search letters , numbers do:
positions = [] y = 0 x in text: if x.isalnum(): positions.append(y) y += 1
that looked before edited question.
Comments
Post a Comment