0

I have a list of products which are strings & want to remove single quotes from it

The list of products retrieved from a sql query in python environment

['000003286694', '000003286704', '000003420412']

I have to pass this list as a payload to json object. So it needs to be preceded by double quotes.

I have used following method d=[('"'+i+'"') for i in x]

but I get the output as ['"000003286694"', '"000003286704"', '"000003420412"']

I tried using regex, replace method to get away with single quotes but no success. Can anyone please share workaround for this

I want result list should be ["000003286694", "000003286704", "000003420412"]

Seema Mudgil
  • 365
  • 1
  • 7
  • 15

1 Answers1

0
    data =['000003286694', '000003286704', '000003420412']
    import json
    result =json.dumps(data)
    print(result)  #["000003286694", "000003286704", "000003420412"]
Tulasi
  • 59
  • 2
  • While this code may answer the question, providing additional context regarding *why* and/or *how* this code answers the question improves its long-term value. – Sneftel Sep 10 '19 at 13:01
  • Using json.dumps will make result as string. I need to use this as a list – Seema Mudgil Sep 11 '19 at 04:21