python - display unicode in Html Widget of iPyWidgets
问题描述
I want to show Unicode text (Persian text) in Jupiter. Currently, I use from HTML widget to show the text likes the following:
# title is unicode
title_value = widgets.HTML(value = title)
But, I've gotten the following error:
TraitError: Could not decode '\xd9\xbe\xda\x98\xd9\x88 405 \xd9\x85\xd8\xb4\xda\xa9\xdb\x8c \xd9\x81\xd8\xb1\xd9\x88\xd8\xb4 90 91' for unicode trait 'value' of a HTML instance.
Anyhow, when print
the title the result would be in Persian.
What supposed to resolve the issue?
I should have mentioned that encode("utf-8")
does not work properly, as I want to show the Unicode text!
解决方案
A simple solution which I found is using decode("utf-8")
:
title_value = widgets.HTML(value = title.decode("utf-8"))
推荐阅读
- rxjs - Combine Observables with latest of any one and previous value of the other observables
- php - Using php Simple HTML DOM Parser
- php - php preg_replace each occurence with different string
- firebase - Zope external file or static resource directory
- spring-boot - Flyway - Cannot find migrations location in
- javascript - How to adjust the Js Chart's label?
- angular - Visual Studio Code can't resolve angular's tsconfig paths
- asp.net-mvc - MVC 设置视图渲染/执行顺序
- python - 如果两个dfs之间的行值相同,则比较两个熊猫数据帧并写入新数据帧
- python - 如何更改 distutils 的输出目录?