我有以下 URL,我想更改start每次迭代的值。有没有更好的方法来做到这一点?
test := "https://www.googleapis.com/customsearch/v1?start=%d&cx=001106611627702700888%3Aaonktv-oz_w&q=bells%20palsy%20mouth&exactTerms=palsy&fileType=png&imgColorType=color&imgType=face&searchType=image&key=AIzaSyAYqQ4IxUHnF7rfvzSvnczxQ-u93AbkC8k"
for v := 1; v < 100; v += 10 {
val := fmt.Sprintf(test, v)
fmt.Println(val)
}
现在输出:
https://www.googleapis.com/customsearch/v1?start=1&cx=001106611627702700888%!A(MISSING)aonktv-oz_w&q=bells%!p(MISSING)alsy%!m(MISSING)outh&exactTerms=palsy&fileType=png&imgColorType=color&imgType=face&searchType=image&key=AIzaSyAYqQ4IxUHnF7rfvzSvnczxQ-u93AbkC8k
预期输出应该是:
https://www.googleapis.com/customsearch/v1?startindex=1&q=bells%20palsy%20mouth
https://www.googleapis.com/customsearch/v1?startindex=11&q=bells%20palsy%20mouth
....等等。
为什么Sprintf给我(MISSING)和几个随机字符?
哆啦的时光机
相关分类