I want to construct a replace statement in my python script

527
2
09-20-2017 07:36 AM
OLANIYANOLAKUNLE
Occasional Contributor II

I want to construct a replace statement in my python script through the following python code below;

arcpy.CalculateField_management("Mainfb_Stage_P","AFileN","!ABFileN!","PYTHON_9.3","replace(ABFileN, "/","-")")   

But i keep getting the error below;

Runtime error
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: unsupported operand type(s) for /: 'str' and 'str'

Anyone with a wonderful suggestion. Thanks

Tags (1)
0 Kudos
2 Replies
RandyBurton
MVP Alum

You might try:

arcpy.CalculateField_management("Mainfb_Stage_P","AFileN","!ABFileN!.replace('/','-')","PYTHON_9.3")
0 Kudos
OLANIYANOLAKUNLE
Occasional Contributor II

Thank you RANDY!!!! You are the best.....

0 Kudos