Using 'string.ljust' to try and hold a fixed width.......

Mel Wilson mwilson at the-wire.com
Wed Nov 19 22:43:26 CET 2003


In article <2c82369d.0311191041.e5b1fa6 at posting.google.com>,
John_Dutcher at urmc.rochester.edu (John F Dutcher) wrote:
>In my CGI script where I retrieve 'form' data nothing works..
>The use of a string to receive the form field first, and
>then appending to 'recd'...or appending to 'recd' directly, both fail
>to preserve the spaces....(which are preserved very well in the
>IDLE mode using a string literal to start with, rather than 'form' data).
>
>  	
>recd = []
>lname = string.ljust(form.getfirst("lname",' '),15)
>fname = string.ljust(form.getfirst("fname",' '),15)
>
>recd.append(lname)
>recd.append(fname)
>
>recstr = string.join(recd,'')
>print recstr   ------------------> no ending spaces


Are you viewing your CGI program's output with an HTML browser?

        Regards.        Mel.




More information about the Python-list mailing list