Hello
How do I handle ' in an attribute table using python?
Example
var = ["'Name"]
any help is greatly appreciated!
Cheers
Chris
Solved! Go to Solution.
I'd just use a backslash as an escape character, that way it doesn't try doesn't crash since there isn't a second single quote to end the string.
var = ["\'Name"]
Generally it not advisable to have special characters in field names, or to have them start with numbers.
I'd just use a backslash as an escape character, that way it doesn't try doesn't crash since there isn't a second single quote to end the string.
var = ["\'Name"]
Generally it not advisable to have special characters in field names, or to have them start with numbers.
Thanks for the idea!
Working code below:
var = ["'\'Name"]
I avoid escape characters by using triple quotes. It is so much easier and more legible.
Except when it is the first character when it is a bit hard to see.