breaking a string
fredrik at pythonware.com
Wed Oct 17 09:06:20 CEST 2001
Michael Yuen wrote:
> I'm pretty new to this Python stuff and i'm trying to figure out how to
> break a string into it's component parts.
> For example, if a line of text in a file is:
> "Hello World!"
> I want to enter that into my list as just ['Hello', 'World']
>>> s = "Hello, World!"
>>> import re
>>> re.findall("\w+", s)
<!-- (the eff-bot guide to) the python standard library:
More information about the Python-list