[Tutor] quicker .strip?
John P Speno
speno at isc.upenn.edu
Fri Jan 9 15:13:54 EST 2004
On Fri, Jan 09, 2004 at 12:22:41PM -0700, firephreek wrote:
> ip=cursor.fetchall()
> ## At this point ip looks like this: (("10.1.1.205"),("10.1.1.206"))
> for x in range(len(ip)):
> alpha=IP_strip(str(ip[x]))
> config=getConfig(alpha) ##Custom function that uses httplib to
>
> I'm wondering if there's any functions/methods that will strip the info
> in fewer lines. Or if there's another way of retrieving my information
> so that I won't have to strip it.
MySQLdb is returning to you a tuple of tuples, not a string. Try something
like this:
ips = cursor.fetchall()
for ip in ips:
print ip
Does that help?
More information about the Tutor
mailing list