大括号是特殊转义字符,如果需要原始的大括号,用{ {代替{, 用}}代替}, 如下:
s = 'id=pc&offset={}&limit=20&strategy=1&ext={
{%22pool%22:[%22high%22,%22top%22],%22is_filter%22:10,%22check_type%22:true}}'
print(s.format(2))
运行结果:
id=pc&offset=2&limit=20&strategy=1&ext={%22pool%22:[%22high%22,%22top%22],%22is_filter%22:10,%22check_type%22:true}