What is rstrip() in python?
Chris Angelico
rosuav at gmail.com
Sun Nov 9 06:28:29 EST 2014
On Sun, Nov 9, 2014 at 10:11 PM, <satishmlmlml at gmail.com> wrote:
> What is rstrip() in python?
>
> What does it do in the following piece of code?
>
> import sqlite3
> conn = sqlite3.connect('dbase1')
> curs = conn.cursor()
>
> file = open('data.txt')
> rows = [line.rstrip().split(',') for line in file]
Do you know what type of object 'line' is here? Do you know what you
get when you iterate over a file?
Get an object of that type in the interactive interpreter, maybe like this:
file = open('data.txt')
line = next(file)
Then you can find out about its methods:
help(line.rstrip)
That should tell you what you want to know.
ChrisA
More information about the Python-list
mailing list