Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: '_io.BufferedReader' object has no attribute 'strip'

Tags:

I've got this error. Why?

File "/k.py", line 257, in deskJ
    eremuak = aFileLine.strip().split('\t')
AttributeError: '_io.BufferedReader' object has no attribute 'strip'

Code

def deskribapenaJaso(self, aFileLine):
    eremuak = aFileLine.strip().split('\t')
    print(eremuak) #printNothing

aFileLine = It's the X line of a file

like image 838
AEU Avatar asked Apr 19 '16 10:04

AEU


1 Answers

You are using str methods on an open file object.

You can read the file as a list of lines by simply calling list() on the file object:

with open('goodlines.txt') as f:
    mylist = list(f)
like image 52
Pavan Gupta Avatar answered Sep 28 '22 04:09

Pavan Gupta