我遇到了这个错误。为什么?
File "/k.py", line 257, in deskJ
eremuak = aFileLine.strip().split('\t')
AttributeError: '_io.BufferedReader' object has no attribute 'strip'
代码
def deskribapenaJaso(self, aFileLine):
eremuak = aFileLine.strip().split('\t')
print(eremuak) #printNothing
aFileLine = 它是文件的 X 行
最佳答案
您正在对打开的文件对象使用 str
方法。
只需在文件对象上调用 list()
即可将文件作为行列表读取:
with open('goodlines.txt') as f:
mylist = list(f)
关于python - AttributeError: '_io.BufferedReader' 对象没有属性 'strip',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36715639/