UnicodeCodeError:' Charmap' (仅使用PHP)
我有一个想获得“阿拉伯语”价值的输入 我做了此代码
token = soup.find('input', {'name':'EmpName'})['value']
print(token)
,它在终端(CMD)中起作用
但是,每当我尝试用PHP打印输出时,就会给我这个错误。
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-3: character
maps to
我使用此PHP代码打印输出,它可以与
<?php echo exec('python q.py 2>&1'); ?>
我尝试添加的
print(token.encode('cp1252'))
print(token.encode('utf-8'))
其他任何内容都无法使用。
I have an input that I want to get the value of in "Arabic"
and I did this code
token = soup.find('input', {'name':'EmpName'})['value']
print(token)
and it works in the terminal ( cmd )
but the real problem that whenever I try to print the output with php it keeps giving me this error.
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-3: character
maps to
I used this PHP code to print the output and it works with anything else
<?php echo exec('python q.py 2>&1'); ?>
I tried to add
print(token.encode('cp1252'))
print(token.encode('utf-8'))
didn't work at all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过添加忽略错误并将其编码到UTF-8,然后将其解码到CP1252 CUZ,将其修复
I fixed it by adding ignore errors and encoding it to utf-8 and then decoding it to cp1252 cuz I'm on windows