-1

我有一个用日语写的字段名称的 shapefile (.shp)。我想使用以下程序以日语阅读字段名称:

import ogr
infile = r"E:\shp\test.shp"
ds = ogr.Open(infile,0); slayer = ds.GetLayer(0)
fieldNames = [slayer.GetLayerDefn().GetFieldDefn(i).GetName() for i in range(0,slayer.GetLayerDefn().GetFieldCount())]

for x in fieldNames:
    print x

但是,它打印出来如下,不可读。

ツwヘW
ツxヘW
’c’n–¼

如何为字段名称获取 readabe 日文文本?

我也试过 as x.decode('utf8'),但收到错误消息UnicodeDecodeError: 'utf8' codec can't decode byte 0x95 in position 0: invalid start byte

小伙伴们怎么做?

4

1 回答 1

0

这里不是积极的,只是想提供帮助,但也许尝试将字符串转换为这样的 unicode 序列?

a = "Hello, World!"
u = unicode(a,'utf-8')

print type(a)
print a
print type(u)
print u

输出:

<type 'str'>
Hello!
<type 'unicode'>
Hello!
于 2015-08-27T16:04:10.227 回答