Equivalent of Perl chomp?
Kragen Sitaker
kragen at pobox.com
Wed Jan 30 17:59:25 EST 2002
"hamish_lawson" <hamish_lawson at yahoo.co.uk> writes:
> Some of the other solutions offered don't remove *all* trailing CR or
> LF characters, as Perl's chomp function does. Here is a version that
> does:
Perl's chomp function doesn't; it removes either nothing or a single
line terminator from the end of the string. The line terminator is
generally "\n", but it could be something else depending on context.
kragen at detached:~/pkgs/Python-211/Objects$ perl -e 'my $x = "a\r\n\r\n"; chomp $x; print $x, "foo\n"' | cat -vte
a^M$
^Mfoo$
More information about the Python-list
mailing list