Formatting a column's value output

Ferrous Cranus nikos.gr33k at gmail.com
Sat Jan 26 20:41:40 CET 2013


Τη Σάββατο, 26 Ιανουαρίου 2013 8:04:12 μ.μ. UTC+2, ο χρήστης Chris Angelico έγραψε:
> On Sun, Jan 27, 2013 at 4:51 AM, Ferrous Cranus <nikos.gr33k at gmail.com> wrote:
> 
> >                                 print ( "<td><b><font color=yellow> %s </td>" % item )
> 
> 
> 
> >
> 
> > In the aboce code wheb 'URL' is to be typed out be print i need it to be formatted as a link, so the viewer can click on it.
> 
> >
> 
> > Is this possible please?
> 
> 
> 
> Easy, just make a tuple of item,item and have two %s markers:
> 
> 
> 
> print( "<td><b><font color=yellow><a href='%s'>%s</a></td>" % (item, item) )
> 
> 
> 
> But you need to concern yourself with escaping. In fact, you already
> 
> needed to, just to produce it as text - but it's now even more
> 
> important. I strongly suggest you look into that.
 
I can use triple (''') quoting so i dont have to escape special characters.

But i didnt understand you suggestion about the tuple.

The dataset returns many lines and i need to transfor only the URL column....
Sorry i did not understood.



More information about the Python-list mailing list