arcade 读取地图信息时:错误: ‘gbk‘ codec can‘t decode byte 0x91 in position 314: illegal multibyte sequence
arcade 读取地图信息时:错误: 'gbk' codec can't decode byte 0x91 in position 314: illegal multibyte sequence
E:\pgame\venv\Scripts\python.exe E:/pgame/arcadegame/game10-地图双层.py
path: E:\pgame\venv\Lib\site-packages\arcade\resources
Traceback (most recent call last):
File "E:/pgame/arcadegame/game10-地图双层.py", line 208, in <module>
main()
File "E:/pgame/arcadegame/game10-地图双层.py", line 203, in main
window.setup()
File "E:/pgame/arcadegame/game10-地图双层.py", line 83, in setup
self.tile_map = arcade.load_tilemap(map_name, TILE_Scaling, layer_options)
File "E:\pgame\venv\lib\site-packages\arcade\tilemap\tilemap.py", line 963, in load_tilemap
offset=offset,
File "E:\pgame\venv\lib\site-packages\arcade\tilemap\tilemap.py", line 187, in __init__
self.tiled_map = pytiled_parser.parse_map(map_file)
File "E:\pgame\venv\lib\site-packages\pytiled_parser\parser.py", line 21, in parse_map
parser = check_format(file)
File "E:\pgame\venv\lib\site-packages\pytiled_parser\util.py", line 42, in check_format
line = file.readline().rstrip().strip()
UnicodeDecodeError: 'gbk' codec can't decode byte 0x91 in position 314: illegal multibyte sequence
错误:
def check_format(file_path: Path) -> str: with open(file_path) as file: # print(file.readline()) line = file.readline().rstrip().strip() if line[0] == "<": return "tmx" else: return "json"
原因:地图文件中有汉字
改为如下后:
def check_format(file_path: Path) -> str: with open(file_path,encoding='utf-8') as file: # print(file.readline()) line = file.readline().rstrip().strip() if line[0] == "<": return "tmx" else: return "json"
此处过去了,但在后面又出现了错误
E:\pgame\venv\Scripts\python.exe E:/pgame/arcadegame/game10-地图双层.py
path: E:\pgame\venv\Lib\site-packages\arcade\resources
Traceback (most recent call last):
File "E:/pgame/arcadegame/game10-地图双层.py", line 208, in <module>
main()
File "E:/pgame/arcadegame/game10-地图双层.py", line 203, in main
window.setup()
File "E:/pgame/arcadegame/game10-地图双层.py", line 83, in setup
self.tile_map = arcade.load_tilemap(map_name, TILE_Scaling, layer_options)
File "E:\pgame\venv\lib\site-packages\arcade\tilemap\tilemap.py", line 963, in load_tilemap
offset=offset,
File "E:\pgame\venv\lib\site-packages\arcade\tilemap\tilemap.py", line 187, in __init__
self.tiled_map = pytiled_parser.parse_map(map_file)
File "E:\pgame\venv\lib\site-packages\pytiled_parser\parser.py", line 25, in parse_map
return tmx_map_parse(file) # type: ignore
File "E:\pgame\venv\lib\site-packages\pytiled_parser\parsers\tmx\tiled_map.py", line 25, in parse
raw_map = etree.parse(map_file).getroot()
File "D:\Python37\lib\xml\etree\ElementTree.py", line 1197, in parse
tree.parse(source, parser)
File "D:\Python37\lib\xml\etree\ElementTree.py", line 598, in parse
self._root = parser._parse_whole(source)
UnicodeDecodeError: 'gbk' codec can't decode byte 0x91 in position 314: illegal multibyte sequence
最终还是放弃在地图中使用中文吧
相关文章
- Summary: Lowest Common Ancestor in a Binary Tree & Shortest Path In a Binary Tree
- An established connection was aborted by the software in your host machine错误
- Spring数据库事务典型错误用法剖析
- VMWare ESXi 开启显卡直通 (PCI 设备直通) 出现 DevicePowerOn 错误
- GConf 错误:联系配置服务器失败;某些可能原因是需要为 ORBit 启用 TCP/IP 联网
- ansible错误ImportError: No module named ansible.runner记录
- tomcat启动时常见错误问题集锦
- MySQL修改字符集步骤(字段插入中文提示错误时解决办法)
- Visual Studio 2013 出现错误 error RC2108: expected numerical dialog constant
- JAVA-错误Several ports (8080, 8009) required by Tomcat v7.0 Server at localhost are already in use.
- dubbo 常见错误
- ERROR in config: Command requires a target workspace.错误解决方案
- 宝塔部署时,出现“open_basedir restriction in effect”错误
- (OperationNotSupportedInTransaction) Cannot create namespace test.application in multi-document transaction 错误的解决方法
- 如何用 Android Studio 导入开源项目以及常见错误的解决办法
- “/”应用程序中的服务器错误和Server Error in '/' Application... 的终极解决方法
- 【AD错误】Details Duplicate pins in component Pin ×× and Pin ××
- Python "'ascii' codec can't decode byte 0xe6 in position 52: ordinal not in range(128)"错误解决
- Python Solve UnicodeEncodeError 'gbk' / 'ascii' / 'utf8' codec can't encode character 'x??' in position ? 解决有关Python编码的错误
- LNMP - Warning: require(): open_basedir restriction in effect错误解决方法
- SVN配置常见错误
- Address already in use: JVM_Bind<null>:8080错误的解决办法
- 调用python 报R6034 错误