Home > Back-end >  How can I do a dictionary format with f-string in Python
How can I do a dictionary format with f-string in Python

Time:07-12

my code is as below

aaa = "['https://google.com', 'https://yahoo.com']"
REQUEST = f'{"siteUrls": {aaa}}'
print(REQUEST)

I've tried

aaa = "['https://google.com', 'https://yahoo.com']"
REQUEST = {"siteUrls": {}}.format(aaa)
print(REQUEST)

and

aaa = "['https://google.com', 'https://yahoo.com']"
REQUEST = {"siteUrls": %s}           
  • Related