UnicodeDecodeError 'utf-8' 编解码器无法解码 - 使用 python shapefile 阅读器

Pau*_*ado 4 python unicode shapefile

我正在尝试读取 shapefile

r = shapefile.Reader(filepath, encoding = "utf-8")
Run Code Online (Sandbox Code Playgroud)

但是当我尝试从.records()对象获取值时,例如:

 r.records()[0]
Run Code Online (Sandbox Code Playgroud)

它返回给我以下错误:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 4: invalid continuation byte
Run Code Online (Sandbox Code Playgroud)

Joe*_*Fan 6

这意味着您的文件不是以 utf-8 编码的。尝试:ISO8859-1

如果您在 Linux 上(或在 Windows 上有 git-bash),您可以使用该file命令来找出编码。