What is rstrip() in python?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun Nov 9 07:57:22 EST 2014


satishmlmlml at gmail.com wrote:

> What is rstrip() in python?

Have you read the Fine Manual?

Did you try googling first?

https://duckduckgo.com/html/?q=python+rstrip


> What does it do in the following piece of code?

It removes trailing whitespace.


> import sqlite3
> conn = sqlite3.connect('dbase1')
> curs = conn.cursor()
> 
> file = open('data.txt')
> rows = [line.rstrip().split(',') for line in file]


-- 
Steven




More information about the Python-list mailing list