"Kent Johnson" <[EMAIL PROTECTED]> wrote in message
>> One final tip is to put the format string in a variable then use
>> that
>> in printing/writing the output ...
>> This has the advantage that you can build the format string
>> dynamically by examining the data first - eg the maximum
>> leng
Alan Gauld wrote:
> others have discussed format strings.
> One final tip is to put the format string in a variable then use that
> in printing/writing the output
>
> eg:
>
> fmt = '%10.3f\t%10.3f\t%10.3f'
> print fmt % v1,v2,v3
>
> This has the advantage that you can build the format string
> d
"Per Jr. Greisen" <[EMAIL PROTECTED]> wrote
> I need to generate a table with different x,y,z values and write
> them to a
> file:
> 10.171 -15.243 -2.558
> 9.837 -14.511 -1.923
> -23.451 -13.870 51.507
>
others have discussed format strings.
One final tip is to put the format string in a va
> -Original Message-
> Date: Tue, 20 Mar 2007 22:53:15 +0100
> From: J?nos Juh?sz <[EMAIL PROTECTED]>
> Subject: Re: [Tutor] Making table
> To: tutor@python.org
> Message-ID:
>[EMAIL PROTECTED]>
> Content-Type: text/plain; charset="iso-8
Dear Barry,
>>Using a formatting string of "%10.4f", these would be rendered as:
>>
>> ' 253.'
>> ' 77.6000
>> '9.0300'
>> '0.0210'
>>
>>This formatting gives the impression that all values but the last are
>>more precise than
Carroll, Barry wrote:
> This formatting gives the impression that all values but the last are
> more precise than they truly are. A scientist or statistician would
> prefer to see something like this:
>
> '254.'
> ' 77.6 '
> ' 9.03 '
> ' 0.0210'
>
> Does numpy or
> -Original Message-
> From: Kent Johnson [mailto:[EMAIL PROTECTED]
> Sent: Monday, March 19, 2007 12:59 PM
> To: Carroll, Barry
> Cc: tutor@python.org
> Subject: Re: [Tutor] Making table
>
> Carroll, Barry wrote:
> >> -Original Message-
> >
Carroll, Barry wrote:
>> -Original Message-
>> Date: Mon, 19 Mar 2007 11:53:06 -0400
>> From: Kent Johnson <[EMAIL PROTECTED]>
>> Most string formatting conversions allow you to specify a width
>> directly. For example,
>> In [61]: value = 3.45678
>> In [63]: "%10.3f" % value
>> Out[63]: '
> -Original Message-
> Date: Mon, 19 Mar 2007 11:53:06 -0400
> From: Kent Johnson <[EMAIL PROTECTED]>
> Subject: Re: [Tutor] Making table
> To: tutor@python.org
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Dave Kuhlman wrote:
> Try ljust and rjust. They are string functions/methods and are
> described here: http://docs.python.org/lib/string-methods.html
>
> Something like the following might work for you:
>
> In [1]: value = 3.45678
> In [2]: ("%0.3f" % value).rjust(10)
> Out[2]: '
On Mon, Mar 19, 2007 at 01:11:27PM +0100, Per Jr. Greisen wrote:
> Hi,
> I need to generate a table with different x,y,z values and write them to a
> file:
> 10.171 -15.243 -2.558
> 9.837 -14.511 -1.923
> -23.451 -13.870 51.507
>
> I would like to write to the files as columns
> 10.171 -15.24
Hi,
I need to generate a table with different x,y,z values and write them to a
file:
10.171 -15.243 -2.558
9.837 -14.511 -1.923
-23.451 -13.870 51.507
I would like to write to the files as columns
10.171 -15.243 -2.558
9.837 -14.511 -1.923
-23.451 -13.870 51.507
0.233 0.453
12 matches
Mail list logo