print "%s"

Beema Shafreen beema.shafreen at gmail.com
Mon Aug 18 16:25:07 CEST 2008


Thanks a lot for your kind suggestions

On Mon, Aug 18, 2008 at 7:07 PM, gundlach <gundlach at gmail.com> wrote:

> The string.join() approach is better for your purpose, but FYI you can
> multiply a string to repeat it:
>
> In [2]: "%s\t" * 6
> Out[2]: '%s\t%s\t%s\t%s\t%s\t%s\t'
>
> - Michael
>
> On Aug 18, 3:27 am, Bruno Desthuilliers <bruno.
> 42.desthuilli... at websiteburo.invalid> wrote:
> > Cameron Simpson a écrit :
> >
> >
> >
> > > On 18Aug2008 11:58, Beema Shafreen <beema.shafr... at gmail.com> wrote:
> > > | In my script i have to print a series of string , so
> > > |
> > > | print "%s\t%s\t%s\t%s\t%s\t%s\t" %("a","v","t","R","s","f")
> > > |
> > > | I need to know instead of typing so many %s  can i write %6s in
> python, as
> > > | we do in C progm.
> >
> > > I hate to tell you this, but "%6s" in C does NOT print 6 strings. It
> > > prints 1 string, right justified, in no less that 6 characters.
> > > C is just like Python in this example.
> >
> > > | What are the other options .
> >
> > > Write a small loop to iterate over the strings. Print a tab before each
> > > string except the first.
> >
> > Or use the str.join method:
> >
> > print "\t".join(list("avtRsf"))
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Beema Shafreen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080818/462b0aa3/attachment.html>


More information about the Python-list mailing list