Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #37781
| References | (2 earlier) <d543dccf-af7a-4efd-adc5-13d9ef080c1e@googlegroups.com> <mailman.1090.1359239220.2939.python-list@python.org> <a8690843-35b0-423e-a79d-f2b6c1991be6@googlegroups.com> <63edba3c-55af-4c4c-a311-4188891bfdf0@googlegroups.com> <f0e08aad-3c69-4ba0-82d0-91652997c7d4@googlegroups.com> |
|---|---|
| Date | 2013-01-27 13:36 -0500 |
| Subject | Re: Formatting a column's value output |
| From | Joel Goldstick <joel.goldstick@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1116.1359311811.2939.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
On Sun, Jan 27, 2013 at 1:05 PM, Κώστας Παπαδόπουλος
<nikos.gr33k@gmail.com>wrote:
> Τη Κυριακή, 27 Ιανουαρίου 2013 6:12:59 μ.μ. UTC+2, ο χρήστης
> ru...@yahoo.com έγραψε:
> > On 01/27/2013 02:04 AM, Ferrous Cranus wrote:
> >
> > >[...]
> >
> > > data = cur.fetchall()
> >
> > > for row in data:
> >
> > > print ( "<tr>" )
> >
> > >
> >
> > > for item in row:
> >
> > > print( '''<td> <a href='http://www.%s?show=log'>%s</a>
> </td>''' % (item, item) )
> >
> > >[...]
> >
> > > Okey, so far BUT i want the url linking to happen only for the URL
> column's
> >
> > > value, and not for the hits column too. How do i apply the url link to
> the
> >
> > > URL column's value only?
> >
> >
> >
> > Ferrous,
> >
> >
> >
> > 'row' has two items (the url and the hit count) in it, right?
> >
> > So print each separately rather than in a loop:
> >
> >
> >
> > data = cur.fetchall()
> >
> > for row in data:
> >
> > url = row[0]
> >
> > hits = row[1]
> >
> > print ( "<tr>" )
> >
> > print( "<td> <a href='http://www.%s?show=log'>%s</a> </td>: %
> (url, hits) )
>
> Yes that can work, but i want to ask you if its possible to do the same
> thing from within the loop as i have it coded it until now.
>
> Is there a way to seperate the values within the loop?
>
for row in data:
print( "<td> <a href='http://www.%s?show=log'>%s</a> </td>: " %
(row[0], row[1]) )
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
Joel Goldstick
http://joelgoldstick.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-26 09:51 -0800
Re: Formatting a column's value output Chris Angelico <rosuav@gmail.com> - 2013-01-27 05:04 +1100
Re: Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-26 11:41 -0800
Re: Formatting a column's value output Michael Torrie <torriem@gmail.com> - 2013-01-26 15:26 -0700
Re: Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-27 01:04 -0800
Re: Formatting a column's value output Chris Angelico <rosuav@gmail.com> - 2013-01-27 20:08 +1100
Re: Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-27 01:16 -0800
Re: Formatting a column's value output Chris Angelico <rosuav@gmail.com> - 2013-01-27 20:26 +1100
Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-27 01:30 -0800
Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-27 01:30 -0800
Re: Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-27 01:16 -0800
Re: Formatting a column's value output rurpy@yahoo.com - 2013-01-27 08:12 -0800
Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-27 10:05 -0800
Re: Formatting a column's value output Joel Goldstick <joel.goldstick@gmail.com> - 2013-01-27 13:36 -0500
Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-27 10:44 -0800
Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-27 10:44 -0800
Re: Formatting a column's value output rurpy@yahoo.com - 2013-01-27 11:12 -0800
Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-27 12:24 -0800
Re: Formatting a column's value output Mitya Sirenef <msirenef@lightbird.net> - 2013-01-27 15:50 -0500
Re: Formatting a column's value output rurpy@yahoo.com - 2013-01-27 14:27 -0800
Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-28 01:47 -0800
Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-28 01:44 -0800
Re: Formatting a column's value output Κώστας Παπαδόπουλος <nikos.gr33k@gmail.com> - 2013-01-28 01:44 -0800
Re: Formatting a column's value output Virgil Stokes <vs@it.uu.se> - 2013-01-27 18:46 +0100
Re: Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-27 01:04 -0800
Re: Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-26 11:41 -0800
Re: Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-26 13:07 -0800
Re: Formatting a column's value output Chris Angelico <rosuav@gmail.com> - 2013-01-27 09:18 +1100
Re: Formatting a column's value output alex23 <wuwei23@gmail.com> - 2013-01-26 15:29 -0800
Re: Formatting a column's value output Chris Angelico <rosuav@gmail.com> - 2013-01-27 10:38 +1100
Re: Formatting a column's value output Jason Friedman <jsf80238@gmail.com> - 2013-02-03 09:18 -0800
Re: Formatting a column's value output Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-04 06:39 +0000
Re: Formatting a column's value output Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-26 13:07 -0800
csiph-web