我想将以下ipython命令的输出捕获到文件中: 命令和输出如下:
`decoder.get_hyp()`
WARNING: "ngram_search.c", line 1000: </s> not found in last frame, using ++NOISE++ instead
INFO: ngram_search.c(1046): lattice start node <s>.0 end node ++NOISE++.171
INFO: ps_lattice.c(1225): Normalizer P(O) = alpha(++NOISE++:171:185) = -2003082
INFO: ps_lattice.c(1263): Joint P(O,S) = -2036704 P(S|O) = -33622
Out[7]: ('WELCOME TO MY TALK', '000000000', -36704586)
我想把"wellcome to my talk"这部分内容单独提取出来放到我的文件里。
%store
命令保存的数据类型(如str
)会被保存为 (<class 'str'>,) 的形式,当使用%load
命令加载时会引发错误... 因此建议使用 pickle! - SeF