小编Rid*_*ima的帖子

python 中出现错误 SyntaxError: f-string: 表达式嵌套太深

我收到此错误,我还需要在该字符串中传递变量,但它为以下代码给出了此错误:

   for i in range (0,4):
str =f'{"requests":[{"indexName":"New_Telemart","params":"query=Mobiles&maxValuesPerFacet=10&page="{i}"&highlightPreTag=__ais-highlight__&highlightPostTag=__%2Fais-highlight__&facets=%5B%22brand_name%22%2C%22categories%22%2C%22sale_price%22%2C%22total_rating_average%22%2C%22express_delivery%22%5D&tagFilters=&facetFilters=%5B%5B%22categories%3ASmartphones%22%2C%22categories%3AMobile%20%26%20Tablets%22%5D%5D"},  {"indexName":"New_Telemart","params":"query=Mobiles&maxValuesPerFacet=10&page=0&highlightPreTag=__ais-highlight__&highlightPostTag=__%2Fais-highlight__&hitsPerPage=1&attributesToRetrieve=%5B%5D&attributesToHighlight=%5B%5D&attributesToSnippet=%5B%5D&tagFilters=&analytics=false&clickAnalytics=false&facets=categories"}]}'
print(str)
Run Code Online (Sandbox Code Playgroud)

错误: 在此输入图像描述

python string syntax python-3.x

0
推荐指数
1
解决办法
2732
查看次数

标签 统计

python ×1

python-3.x ×1

string ×1

syntax ×1