擅长:python、mysql、java
<p>在<code>for</code>循环之前,可以对<code>xseq</code>和<code>yseq</code>上的每个字符串元素使用<code>encode('utf-8')</code>方法。在</p>
<p>我的<code>xseq</code>中的一个元素现在看起来像这样<code>[b'nxtletter=<\xc3\xad']</code></p>
<p>这是我的密码</p>
<pre class="lang-py prettyprint-override"><code>def sent2features(data):
return [extractFeatures(sent) for sent in data]
def sent2labels(data):
return [extractLabels(sent) for sent in data]
X_train = sent2features(train_data)
Y_train = sent2labels(train_data)
for xseq, yseq in zip(X_train, Y_train):
trainer.append(xseq, yseq)
</code></pre>
<p><code>extractFeatures</code>和<code>extractLabels</code>函数上的编码行如下所示</p>
^{pr2}$
<p>也许对你有用。祝你好运!在</p>