【发布时间】:2017-04-17 07:18:33
【问题描述】:
PHP 中存在这样的系统调用
system("python3 returnUTF8.py")
如果我在 Linux 命令行上运行 Python 脚本 - 它工作正常,但是当我使用 PHP 系统命令时,我收到错误“UnicodeEncodingError - 无法编码为 ascii”...
我理解问题在于 Python 中的打印函数默认为调用者想要的结果,当我在命令行上运行 print (sys.stdout.encoding) 时我得到 UTF-8 并从系统调用中得到 @ 987654324@.
如何更改 PHP 或 Python 脚本中的系统调用以使用 UTF-8 编码?
【问题讨论】:
标签: php linux bash python-3.x system