chomp()

Ben Caradoc-Davies bmcd at es.co.nz
Mon Jun 21 17:45:59 EDT 1999


On Mon, 21 Jun 1999 14:08:52 -0700, Angus MacKay <amackay at starvision.com> wrote:
>is there an equivilent of perl's chomp() in python or
>do I have to write the function myself?

string.rstrip(s) strips all trailing whitespace characters from s. If you
really, really, want your trailing whitespace, try

if s[-1]=='\n': s = s[:-1]

-- 
Ben Caradoc-Davies <bmcd at es.co.nz>




More information about the Python-list mailing list