Questions tagged «unicodeencodeerror»

3
使用ArcPy和Python替换属性表中的非英文字符?
我有一些shapefile,其中某些属性包含非英语字符ÅÄÖ。由于某些查询不适用于这些字符(特别是ChangeDetector),因此我尝试使用一个简单的脚本预先更改它们,并将新字符串添加到另一个字段中。 但是,更改字符效果很好,但不能使用arcpy.UpdateCursor更新该字段。 解决这个问题的合适方法是什么? 我也曾尝试通过字段计算器来执行此操作,同时将“代码”发布到代码块中,出现相同的错误。 错误消息: 运行时错误回溯(最近一次调用最近):文件“”,行1,在文件“ c:/gis/python/teststring.py”,行28,在val =代码(str(prow.Typkod)) UnicodeEncodeError:'ascii'编解码器无法在位置3处编码字符u'\ xc4':顺序号不在范围内(128) 码: # -*- coding: cp1252 -*- def code(infield): data = '' for i in infield: ## print i if i == 'Ä': data = data + 'AE' elif i == 'ä': data = data + 'ae' elif i == 'Å': …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.