我是靠谱客的博主 活力八宝粥,最近开发中收集的这篇文章主要介绍UnicodeEncodeError: ‘ascii‘ codec can‘t encode character u‘\u548c‘ in position 10804: ordinal not in,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

[ INFO] [1618190102.105317159]: waitForService: Service [/gazebo/set_physics_properties] has not been advertised, waiting…
Traceback (most recent call last):
File “/home/gym-gazebo/gym_gazebo/envs/installation/catkin_ws/src/gazebo_ros_pkgs/gazebo_ros/scripts/spawn_model”, line 240, in
exit_code = sm.run()
File “/home//gym-gazebo/gym_gazebo/envs/installation/catkin_ws/src/gazebo_ros_pkgs/gazebo_ros/scripts/spawn_model”, line 150, in run
xml_parsed = xml.etree.ElementTree.fromstring(model_xml)
File “/usr/lib/python2.7/xml/etree/ElementTree.py”, line 1311, in XML
parser.feed(text)
File “/usr/lib/python2.7/xml/etree/ElementTree.py”, line 1657, in feed
self._parser.Parse(data, 0)
UnicodeEncodeError: ‘ascii’ codec can’t encode character u’u548c’ in position 10804: ordinal not in range(128)
[ INFO] [1618190102.806404389]: waitForService: Service [/gazebo/set_physics_properties] is now available.
[ INFO] [1618190102.845202393, 0.021000000]: Physics dynamic reconfigure ready.
[spawn_urdf-4] process has died [pid 6697, exit code 1, cmd /home//gym-gazebo/gym_gazebo/envs/installation/catkin_ws/src/gazebo_ros_pkgs/gazebo_ros/scripts/spawn_model -urdf -model turtlebot3_burger -x -2.16 -y 0.08 -z 0.0 -param robot_description __name:=spawn_urdf __log:=/home/.ros/log/8059873a-9b2c-11eb-b50d-80a5895d0be9/spawn_urdf-4.log].
log file: /home//.ros/log/8059873a-9b2c-11eb-b50d-80a5895d0be9/spawn_urdf-4*.log

解决办法:

指定文件字符集为utf-8
这里是spawn_model
在文件头部加入以下代码:

import sys

reload(sys)

sys.setdefaultencoding(‘utf-8’)

参考:https://www.cnblogs.com/zeze/p/8137734.html

最后

以上就是活力八宝粥为你收集整理的UnicodeEncodeError: ‘ascii‘ codec can‘t encode character u‘\u548c‘ in position 10804: ordinal not in的全部内容,希望文章能够帮你解决UnicodeEncodeError: ‘ascii‘ codec can‘t encode character u‘\u548c‘ in position 10804: ordinal not in所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(51)

评论列表共有 0 条评论

立即
投稿
返回
顶部