gpt4 book ai didi

python - AttributeError: '_io.BufferedReader' 对象没有属性 'strip'

转载 作者:行者123 更新时间:2023-11-28 18:31:37 36 4
gpt4 key购买 nike

我遇到了这个错误。为什么?

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/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com