Convert string to char array

Mike Kent mrmakent at cox.net
Tue Jul 1 14:58:55 EDT 2008


On Jul 1, 2:49 pm, "Brandon" <deanfamil... at verizon.net> wrote:
> How do I convert a string to a char array?  I am doing this so I can edit
> the string received from an sql query so I can remove unnecessary
> characters.

Answering your specific question:

Python 2.5.1 (r251:54863, Mar 31 2008, 11:09:52)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> s = 'hello'
>>> l = list(s)
>>> l
['h', 'e', 'l', 'l', 'o']
>>>

But more generally, you might want to read up on the string methods
available to you, such as replace():
http://docs.python.org/lib/string-methods.html



More information about the Python-list mailing list