Python Chinese Characters in ArcGIS)

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.