How to print character arrays in Python
06 Jun 2011I've come across this problem a number of times, so here's a reminder. When printing in Python, occasionally I'll end up with something like this:
>>> print "foo=%s" % row["Name"]
foo=array('c', 'bar')
The solution is to use the .tostring()
method:
>>> print "foo=%s" % row["Name"].tostring()
foo=bar
Add a comment:
Name and email required; email is not displayed.
Related Posts
QRP weekend 08 Oct 2018
Open Source Cubesat Workshop 2018 03 Oct 2018
mpd crash? try removing files in /var/lib/mpd/ 11 Aug 2018