92
>>> 'test string\n'.rstrip() 'test string'
>>> 'test string \n \r\n\n\r \n\n'.rstrip() 'test string'
>>> 'test string \n \r\n\n\r \n\n'.rstrip('\n') 'test string \n \r\n\n\r '
>>> s = " \n\r\n \n abc def \n\r\n \n " >>> s.strip() 'abc def' >>> s.lstrip() 'abc def \n\r\n \n ' >>> s.rstrip() ' \n\r\n \n abc def'
82
>>> text = "line 1\nline 2\r\nline 3\nline 4" >>> text.splitlines() ['line 1', 'line 2', 'line 3', 'line 4']
71
>>> 'Mac EOL\r'.rstrip('\r\n') 'Mac EOL' >>> 'Windows EOL\r\n'.rstrip('\r\n') 'Windows EOL' >>> 'Unix EOL\n'.rstrip('\r\n') 'Unix EOL'
>>> "Hello\n\n\n".rstrip("\n") "Hello"
65
$x="a\n"; chomp $x
x="a\n" x.rstrip()
56
import os s = s.rstrip(os.linesep)