adjust

S

saif.shakeel

Hi,
How do i right adjust my output using python.I need a output
something like this:
DID= 0x01,0x02,0x03,0x05,0x06,0x07,0x2B,0x30,0x31,0x4D,0x4E,
0x51,0x52,0x53,0x55,
minlength= 3, 3, 4, 2, 10, 10, 40, 2, 150, 4, 1,
2, 2, 1, 2, 1, 6, 3, 17, 1,
maxlength= 3, 3, 4, 2, 10, 10, 40, 2, 150, 4, 1,
2, 2, 1, 2, 30, 6, 3, 17, 20

I am printing from a list, and the values shld print below each id
like shown.
Thx
 
D

Diez B. Roggisch

Hi,
How do i right adjust my output using python.I need a output
something like this:
DID= 0x01,0x02,0x03,0x05,0x06,0x07,0x2B,0x30,0x31,0x4D,0x4E,
0x51,0x52,0x53,0x55,
minlength= 3, 3, 4, 2, 10, 10, 40, 2, 150, 4, 1,
2, 2, 1, 2, 1, 6, 3, 17, 1,
maxlength= 3, 3, 4, 2, 10, 10, 40, 2, 150, 4, 1,
2, 2, 1, 2, 30, 6, 3, 17, 20

I am printing from a list, and the values shld print below each id
like shown.
Thx

http://docs.python.org/lib/typesseq-strings.html

Diez
 
M

Michael Hoffman

How do i right adjust my output using python.
http://docs.python.org/lib/typesseq-strings.html

minlength= 3, 3, 4, 2, 10, 10, 40, 2, 150, 4, 1,
2, 2, 1, 2, 1, 6, 3, 17, 1,

Something like:
.... expanded_text = ",".join("%4d" % item for item in sequence)
.... print "%s=%s" % (label, expanded_text)
....minlength= 3, 3, 4, 2, 10, 10, 40, 2, 150, 4, 1

Completing with a trailing ",", using the entire sequence instead of a
subset, and dealing with your hex constants are left as an exercise to
the reader.
 
A

A.T.Hofkamp

Hi,
How do i right adjust my output using python.I need a output
something like this:
DID= 0x01,0x02,0x03,0x05,0x06,0x07,0x2B,0x30,0x31,0x4D,0x4E,
0x51,0x52,0x53,0x55,
minlength= 3, 3, 4, 2, 10, 10, 40, 2, 150, 4, 1,
2, 2, 1, 2, 1, 6, 3, 17, 1,
maxlength= 3, 3, 4, 2, 10, 10, 40, 2, 150, 4, 1,
2, 2, 1, 2, 30, 6, 3, 17, 20

I am printing from a list, and the values shld print below each id
like shown.
Thx

Collect the data to print in rows underneath each other in a list for each
column, decide how wide each column should become, and finally, print out each
line using the computed widths.

Albert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top