Select to view content in your preferred language

string format question

3159
1
Jump to solution
09-17-2014 07:58 PM
H_A_D_Padmasiri
Deactivated User

dear sir

 

a ="BOUND-B-GEN"

env.workspace = r"E:\Gampaha\51027202\CM51027202.gdb\CM51027202"

newName = arcpy.AddFieldDelimiters(env.workspace, "PCL_LN_DL")

 

 

I want to format following style

"PCL_LN_DL" = 'BOUND-B-GEN'

 

 

I tried to format following way

where = newName + '=' + '{0}{1}{2}'.format ('\'',str(a),'\'')

 

 

But it gives me wrong result, how to add single quote around BOUND-B-GEN

pl help me.

 

 

Thanks

 

 

Padmasiri

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
curtvprice
MVP Alum

# want: "PCL_LN_DL" = 'BOUND-B-GEN'

# tried:

a ="BOUND-B-GEN"

where = newName + '=' + '{0}{1}{2}'.format ('\'',str(a),'\'')

Try this:

a ="BOUND-B-GEN"

newName = "PCL_LN_DL"

where = '"{}" = \'{}\''.format(newName, a)

# or

where = "\"{}\" = '{}'".format(newName, a)

# or

where = "\"{0}\" = '{1}'".format(newName, a)

View solution in original post

0 Kudos
1 Reply
curtvprice
MVP Alum

# want: "PCL_LN_DL" = 'BOUND-B-GEN'

# tried:

a ="BOUND-B-GEN"

where = newName + '=' + '{0}{1}{2}'.format ('\'',str(a),'\'')

Try this:

a ="BOUND-B-GEN"

newName = "PCL_LN_DL"

where = '"{}" = \'{}\''.format(newName, a)

# or

where = "\"{}\" = '{}'".format(newName, a)

# or

where = "\"{0}\" = '{1}'".format(newName, a)

0 Kudos