[英]How can I do a dictionary format with f-string in Python
我的代码如下
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)
他们都没有工作
请求必须是字典。
请帮忙。
尝试这个
aaa = "['https://google.com', 'https://yahoo.com']"
REQUEST = {"siteUrls": f"{aaa}"}
print(REQUEST)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.