English

How To: Insert a quotation mark into a label expression using Python

Summary

The label expression dialog in ArcMap does not respect the exact standards of Python syntax. When trying to insert a quotation mark (") using an escape character, (for example "\""), an invalid expression error is returned. To get around this limitation and insert a quotation mark into a label, perform the following procedure.

Procedure

Use the Unicode character '\x22' in place of the quotation mark, as shown in the following two examples:

Simple label expression:

Code:
[Label] + '\x22'


Advanced label expression:

Code:
def FindLabel ( [Label] ):
return [Label] + '\x22'

Related Information