python encoding problem?

Discussion created by teny on Sep 25, 2013
Latest reply on Sep 25, 2013 by teny
Hello, I know that this theme was discussed few times, but I didnt solve the problem using informations that I've found here.

There is (for many of you well known) problem with coding.

<type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode character u'\xa0' in position 11: ordinal not in range(128)

I enter ID number (data type string) but the script ends with error.
I have tried .encode('utf-8'), .replace(u'\xa0', ' ') but it was no solution.

First - problematic - part of the script is below:

import arcpy, sys, os, shutil
from arcpy import env

arcpy.env.overwriteOutput = True

obecJmeno = arcpy.GetParameter(0)
adr_puvodni = u"C:\\vydej2\\mapy_!empty_2013"
if vyberZ=="obec":
    vyber= "C:\\vydej2\\Data\\CZ020STCE11obc_poly.shp"
    sqlstat= "\"KOD_OBC_TX\"=" + "'" + ID+ "'"
elif vyberZ=="opu":
    vyber= "C:\\vydej2\\Data\\CZ020STCE11opu_poly.shp"
    sqlstat= "\"KOD_OPU_TX\"=" + "'" + ID+ "'"

Any ideas please?

Btw - this script was fully working yesterday on my collegues computer. Today it doesnt work at his PC as well as at mine.

ArcGIS 10.0 build 4400