Using ArcMap 10.8.1
The following Python script ran successfully about 3 weeks ago.
I wrote the script in Notepad. Then saved it from the Field Calculator.
Load it today and I get: Error 000539: Runtime error Syntax Error: encoding declaration in Unicode string (<string>, line 0)
Notepad shows the file is encoded UTF-16 LE. I have read that Python uses UTF-8 by default. I have tried (based on suggestions on other forums) using a coding syntax like:
# _*_ coding: UTF-16 LE _*_
in first line of the Pre-Logic Script Code but that doesn't work and I don't really know what I am doing with that.
Seems like something basic is fouling the script up. Thanks for your suggestions.
Attached: screen shot of the Field Calculator window.
Script:
def Blockname(Species):
if Species = "Olneya tesota":
return "PINV-OT"
elif Species = "Parkinsonia florida":
return "PINV-PF
elif Species = "Parkinsonia microphylla":
return "PINV-PM
else:
return "NA"
__esri_field_calculator_splitter__
Blockname(!Species!)