Lee Capps lcapps at cteresource.org
Wed Dec 12 14:25:16 CET 2007


On Dec 11, 2007, at 5:14 PM, katie smith wrote:

> "[16, 16, 2, 16, 2, 16, 8, 16]"

Regular expressions might be a good way to handle this.

import re

s = '[16, 16, 2, 16, 2, 16, 8, 16]'
get_numbers = re.compile('\d\d*').findall

numbers = [int(x) for x in get_numbers(s)]

See:

http://docs.python.org/lib/module-re.html

---
Lee Capps
Technology Specialist
CTE Resource Center
lcapps at cteresource.org





More information about the Python-list mailing list