我有一个PHP脚本,它用参数调用python脚本,并从python返回几个带有print
的字符串。在
如果python返回unicode字符,它们将无法在浏览器中正确显示。
如果PHP通过参数向python发送unicode字符,它就会中断。在
Python代码:
# -*- coding: UTF8 -*-
from lxml import html
hparser = html.HTMLParser(encoding="utf-8")
tree = html.parse(url, hparser)
## stuff here..
a = a_el.text.encode("utf-8")
b = b_el.text.encode("utf-8")
print [a, b]
PHP代码:
^{pr2}$浏览器中的输出要么给我\xc3\c85
一些东西,要么给我一个黑色菱形的问号。
我试过使用utf8_encode($string)
,但没用。在
我也做了一些研究,但运气不好。
我希望能够从PHP向python发送/接收unicode字符。在
目前没有回答
相关问题 更多 >
编程相关推荐