【发布时间】:2022-07-12 00:40:50
【问题描述】:
我的代码如下
aaa = "['https://google.com', 'https://yahoo.com']"
REQUEST = f'{"siteUrls": {aaa}}'
print(REQUEST)
我试过了
aaa = "['https://google.com', 'https://yahoo.com']"
REQUEST = {"siteUrls": {}}.format(aaa)
print(REQUEST)
和
aaa = "['https://google.com', 'https://yahoo.com']"
REQUEST = {"siteUrls": %s}%aaa
print(REQUEST)
他们都没有工作
REQUEST 必须是字典。
请帮忙。
【问题讨论】:
标签: python dictionary formatting f-string