Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python >;的操作数类型不受支持>;:';内置函数或方法';和'_io.TextIOWrapper';_Python_Json_Unsupportedoperation - Fatal编程技术网

Python >;的操作数类型不受支持>;:';内置函数或方法';和'_io.TextIOWrapper';

Python >;的操作数类型不受支持>;:';内置函数或方法';和'_io.TextIOWrapper';,python,json,unsupportedoperation,Python,Json,Unsupportedoperation,这是我的代码: 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

这是我的代码:

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 out of memory."],
                                timeout=max_expected_time)
    incoming = self.corenlp.before
    lag = incoming.split(b"\r\n")
    incoming = b"\r\n".join(lag).decode('latin-1').encode('utf-8')
    if t == 1:
        # TIMEOUT, clean up anything left in buffer
        print >>sys.stderr, {'error': "timed out after %f seconds" % max_expected_time,
                                 'input': to_send,
                                 'output': incoming}
        raise TimeoutError("Timed out after %d seconds" % max_expected_time)
    elif t == 2:
                # EOF, probably crash CoreNLP process
        print >>sys.stderr, {'error': "CoreNLP terminates abnormally while parsing",
                                 'input': to_send,
                                 'output': incoming}
        raise ProcessError("CoreNLP process terminates abnormally while parsing")
    elif t == 3:
                # out of memory
        print >>sys.stderr, {'error': "WARNING: Parsing of sentence failed, possibly because of out of memory.",
                                 'input': to_send,
                                 'output': incoming}
        raise OutOfMemoryError

    if VERBOSE:
        print("%s\n%s" % ('=' * 40, incoming))
    try:
        results = parse_parser_results(incoming)
    except ixception as e:
        if VERBOSE:
            print(traceback.format_exc())
        raise e

    self.pre_loaded_analisys_dict[to_send] = results

    with open(self.pre_analysis,"w", encoding = 'utf-8') as f:
        json.dump(self.pre_loaded_analisys_dict,f)

    return results
我遇到了这个错误(我正在解析很多术语,这是我第一次遇到这个错误):

>>不支持的操作数类型:“内置函数”或“方法”和“\u io.TextIOWrapper”

有什么想法吗

编辑:printint传入变量我有:

b'Q\r\n注释管道计时信息:\r\n注释器: 0.0秒。\r\n注释器:0.0秒。\r\n注释器:0.0秒。\r\n注释器:0.1秒。\r\n注释器:0.4秒。\r\n注释器:0.6秒。对于606.1的337个代币 令牌/秒。\r\n管道设置:0.0秒。\r\n完成的总时间 StanfordCoreNLP管道:138.7秒。\r\n'

当我应该得到这样的东西时:

b'膝盖挫伤\r\n内容#1(3个标记):\r\n讨论 膝盖\r\n[Text=挫伤CharacterOffsetBegin=0 CharacterOffsetEnd=9 PartOfSpeech=NN引理=挫伤名称DentityTag=O][Text=of CharacterOffsetBegin=10 CharacterOffsetEnd=12 PartOfSpeech=引理中=的 NamedEntityTag=O][Text=knee CharacterOffsetBegin=13 CharacterOffsetEnd=17 PartOfSpeech=NN引理=膝关节名称DentityTag=O]\r'


一个姗姗来迟的答案寻找人们遇到这个特定错误消息的问题:它表示您正试图在Python3中使用Python2样式的流重定向,或者Python2.x中的
from\uuuuuuuuuuuuuuuuuuu导入print\u函数
有效

与其写
print>>sys.stderr,expression
,不如写
print(expression,file=sys.stderr)


提供有关此更改的详细信息。

错误发生在哪一行?我有这样一条信息:“注释管道计时信息…”