How to check for empty string?

المشرف العام

Administrator
طاقم الإدارة
I am running a loop to go through tables of a database's feature classes to rewrite the URL links that are currently in the records. The first elif statement is to check whether there is an empty string or not and to proceed by doing nothing. I wrote this in because the first if statement that also accounts for NULL values does not check for empty strings. Instead, the script just uses the last elif and writes the URL with no filename at the end. All other conditions are fine.

parish = arcpy.GetParameterAsText(0)arcpy.AddMessage('Parish Name = --> "{}"'.format(parish))field = 'Photo1'path = r"http://website.gov/Photos/"for fc in arcpy.ListFeatureClasses(): arcpy.AddMessage('Processing Feature class -->"{}"'.format(fc)) rows = arcpy.UpdateCursor(fc) for row in rows: photolink = row.getValue(field) arcpy.AddMessage('Current Photo1 value -->"{}"'.format(row.Photo1)) if not photolink: pass elif photolink == "": pass elif photolink[:4] == "http": arcpy.AddMessage('Photolink If statement worked') photolinkMod = photolink.split(r'/') photo = str(photolinkMod[len(photolinkMod) - 1]) arcpy.AddMessage('New Photo1 value -->"{}"'.format(photo)) row.setValue(field, path + parish + r"/" + photo) rows.updateRow(row) elif photolink: row.setValue(field, path + parish + r"/" + photolink) rows.updateRow(row)

أكثر...
 
أعلى