我有这个错误。为什么?
File "/k.py", line 257, in deskJ
eremuak = aFileLine.strip().split('\t')
AttributeError: '_io.BufferedReader' object has no attribute 'strip'
Run Code Online (Sandbox Code Playgroud)
代码
def deskribapenaJaso(self, aFileLine):
eremuak = aFileLine.strip().split('\t')
print(eremuak) #printNothing
Run Code Online (Sandbox Code Playgroud)
aFileLine = 它是文件的 X 行
我已收到此错误
File "/class.py", line 246, in __init__
if d and self.rf == 2 and d["descriptionType"] in ["900000000000003001"] and d["conceptId"] in konZer.zerrenda:
TypeError: 'Desk' object is not subscriptable
Run Code Online (Sandbox Code Playgroud)
我创建了这个对象
class Desk:
descriptionId = ""
descriptionStatus = ""
conceptId = ""
term = ""
Run Code Online (Sandbox Code Playgroud)
我在另一堂课上叫它
class DescriptionList():
def deskJ(self,line):
er = line.strip().split('\t')
desc = Desk()
if er[1] == "0":
desc.descriptionId = er[0]
desc.descriptionStatus = er[1]
desc.conceptId = er[2]
desc.term = er[3]
return description
Run Code Online (Sandbox Code Playgroud)
然后我在init调用了函数“ deskJ”,并在此部分得到了错误(我删除了该函数的某些部分):
def __init__(self,fitx,konZer,lanZer={}):
with codecs.open(fitx,encoding='utf-8') as …Run Code Online (Sandbox Code Playgroud) 这是我的代码:
def _parse(self, text):
"""
This is the core interaction with the parser.
It returns a Python data-structure, while the parse()
function returns a JSON object
"""
# CoreNLP interactive shell cannot recognize newline
if '\n' in text or '\r' in text:
to_send = re.sub("[\r\n]", " ", text).strip()
else:
to_send = text
self.corenlp.sendline(to_send)
max_expected_time = max(300.0, len(to_send) / 3.0)
# repeated_input = self.corenlp.except("\n") # confirm it
t = self.corenlp.expect(["\nNLP> ", pexpect.TIMEOUT, pexpect.EOF,
"\nWARNING: Parsing of sentence failed, possibly because of …Run Code Online (Sandbox Code Playgroud)