Here, we only use Chinese characters when calling python in arctoolbox of ArcGIS.
1. If the standard parameter passed in method is the same as the string usage method, there is nothing special. For example
Grouplayer_name = arcpy. getparameterastext (0) # input variables with Chinese characters
The following format is directly used to determine equality:
Lyr. Name = grouplayer_name
Operations between variables are used here. No direct Chinese characters are used. ArcGIS uses unicode encoding by default.
2. Use a Chinese character string directly in the program. This must be encoded for conversion, as shown in figure
Sgrouplayer_name = "layer group 1". Decode ('gb2312 ')
Here, decode is used to convert other encoded strings into unicode encoding, which means to convert str1 encoded in gb2312 to unicode encoding. Encode is used to convert unicode encoding to other encoded strings, meaning to convert the unicode encoded string str2 to gb2312 encoding. Therefore, during transcoding, you must first understand the encoding of the STR string, decode into Unicode, and then encode into other encodings.
From: http://www.gisall.com/html/98/16398-5805.html