擅长:python、mysql、java
<p>通过将.decode('utf-8')添加到\u repr_svg\方法的末尾来解决:</p>
<pre><code>def _repr_svg_(self):
fig, ax = plt.subplots()
ax.plot(self.x,self.y)
plt.legend()
from io import BytesIO
output = BytesIO()
fig.savefig(output, format='svg')
data=output.getvalue() # .encode('utf-8') doesn't change anything
plt.close(fig)
return data.decode('utf-8')
</code></pre>
<p>很抱歉吵闹了:-/</p>