user308827
user308827

Reputation: 21961

replace quotes in python list

   e = '[{lat:-34.92967677667683,lng:-62.34831333160395},{lat:-34.93002861969753,lng:-62.360866069793644},{lat:-34.93526211379422,lng:-62.36063016609785},{lat:-34.93571078689853,lng:-62.35996507775451},{lat:-34.935798629937075,lng:-62.34816312789911},{lat:-34.9333358703344,lng:-62.34824895858759},{lat:-34.9320340961022,lng:-62.348334789276066}]'

I want to replace lat with "lat" and lng with "lng". However, this does not work:

e.replace('lat', "lat")

Upvotes: 1

Views: 54

Answers (3)

oynozan
oynozan

Reputation: 189

e.replace("lat","\"lat\"")

You can use \ for escaping special chars like " '

Upvotes: 1

Sandrin Joy
Sandrin Joy

Reputation: 1169

e=e.replace("lat","\"lat\"")

For replacing with an escape sequence. ,you always have to put an \ backslash before it

Upvotes: 0

Ivan Velichko
Ivan Velichko

Reputation: 6709

Try e.replace('lat', '"lat"').

Upvotes: 3

Related Questions