I have a variable that looks like this:
data = {"add_content": {"errata_ids": [advisory]},"content_view_version_environments": [{"content_view_version_id": version_id}]}
I need to add single quotes to this variable , i.e. if I will assign the variables:
advisory
and version_id
and add the single quotes to data variable like this:
data = '{"add_content": {"errata_ids": ["RHSA-2017:1390"]},"content_view_version_environments": [{"content_view_version_id": 160}]}'
I am able to post to the API
I have tried to add the single quotes in variety of ways:
new_data = "'" + str(data) + "'"
>>> new_data
'\'{\'add_content\': {\'errata_ids\': [\'"RHSA-2017:1390"\']}, \'content_view_version_environments\': [{\'content_view_version_id\': \'160\'}]}\''
or using:
'"%s"'%(data)
and a few more ways.
How can I add the single quotes to the outer to the data variable before and after the opening {
and closing }
?