Select to view content in your preferred language

Python lower string?

2626
11
Jump to solution
10-22-2014 05:16 AM
JohannesBierer
Frequent Contributor

After insert lower() there's nothing written in the field? What's wrong?

# Process: Feld berechnen

arcpy.CalculateField_management(FeldHinzugefuegt, "Pfad", "\"U:\\rips\\images\\tk50\\tk\" & ([BLATT_NR].lower()) & \"co\" & \"*.*\"", "VB", "")

0 Kudos
11 Replies
JohannesBierer
Frequent Contributor

Python is to strange for me.

VB goes through - thanks Curtis ...

0 Kudos
curtvprice
MVP Alum

Your string is pretty complicated. You have it working in VB, great. If you decide you need to make it work in Python, I suggest dinking around at the Python command prompt. Turns out I did it wrong, see my trial and error here. I fixed the string in my post above - so nice you can edit your posts here!

# what I originally posted, wrong

>>> "\'U:\\rips\\images\\tk50\\tk\'" "\'{}\\co\\*.*\'.format(!BLATT_NR!).lower()"

"'U:\\rips\\images\\tk50\\tk''{}\\co\\*.*'.format(!BLATT_NR!).lower()"

# try again

# Note the python must evaluate to a string expression

# for the CalculateField tool

>>> ("\"U:\\rips\\images\\tk50\\tk"

...  "{}\\co\\*.*\".format(!BLATT_NR!).lower()")

'"U:\\rips\\images\\tk50\\tk{}\\co\\*.*".format(!BLATT_NR!).lower()'

0 Kudos