Let\'s say I\'m parsing a file, which uses ; as the comment character. I don\'t want to parse comments. So if I a line looks like this:
;
example.com.
So you'll want to split the line on the first semicolon, take everything before it, strip off any lingering whitespace, and append a newline character.
rtr = line.split(";", 1)[0].rstrip() + '\n'
Links to Documentation: