Select to view content in your preferred language

String format help

1953
3
11-18-2014 10:40 PM
H_A_D_Padmasiri
Deactivated User

Dear sir

String = "BLVF"

I want to format string  to  \"BLVF\".

I tried it like "\'{}\'".format(String)

It gives me wrong answer. pl give me a help to format this

Thanks

Padmasiri

0 Kudos
3 Replies
curtvprice
MVP Esteemed Contributor

You said this didn't work:

"\'{}\'".format(String)

I suggest this:

'"{}"'.format(string)

I good way to test this kind of thing is at the Python command line. This prints the string representation of the result, in this example, the output is: double quote, t, e, s, t, double quote:

>>> '"{}"'.format("test")

'"test"'

>>> '"\\test\\"'

'"\\test\\"'

TimothyHales
Esri Notable Contributor

I've moved your post into the Python space. You will get a much better answer here as the GeoNet Help is intended for community help and feedback. You can see more on the community structure, and what topics are under each space from the following documents:

GeoNet Community Structure

ArcGIS Discussion Forums Migration Strategy

Thanks!

Timothy

0 Kudos
AnthonyGiles
Honored Contributor

Padmasiri,

Try this:

string = "BLVF"

print '"\\' + string + '\\"'

0 Kudos