亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

這構建得很好。為什么這段代碼不執行?

這構建得很好。為什么這段代碼不執行?

Go
慕桂英546537 2022-01-10 14:40:10
我正在嘗試使用 go 制作網絡爬蟲。我構建了這段代碼。它構建良好,沒有任何錯誤。但它的二進制文件不會執行。這是大量例程或執行函數中的那些變量的問題嗎?package mainimport (    "io/ioutil"    "net/http"    //"regexp")func excuter(count int) {    adrr := string("http://torhit.com/torbite/?page=" + string(count))    resp, _ := http.Get(adrr)    bytes, _ := ioutil.ReadAll(resp.Body)    ioutil.WriteFile("scrap.txt"+string(count), bytes, 0777)    resp.Body.Close()}func main() {    //re := regexp.MustCompile("")    count := 1    maxcount := 200    for ; count <= maxcount; count++ {        go excuter(count)    }}    package mainimport (    "io/ioutil"    "net/http"    //"regexp")func excuter(count int) {    adrr := string("http://torhit.com/torbite/?page=" + string(count))    resp, _ := http.Get(adrr)    bytes, _ := ioutil.ReadAll(resp.Body)    ioutil.WriteFile("scrap.txt"+string(count), bytes, 0777)    resp.Body.Close()}func main() {    //re := regexp.MustCompile("")    count := 1    maxcount := 200    for ; count <= maxcount; count++ {        go excuter(count)    }}
查看完整描述

1 回答

?
幕布斯6054654

TA貢獻1876條經驗 獲得超7個贊

也許你的錯誤來自這個:

string(count)

它將編譯但結果為空。如果要將 int 轉換為 string,則需要 strconv 包。

strconv.Itoa(count)

或者

strconv.FormatInt(int64(count), 10)


查看完整回答
反對 回復 2022-01-10
  • 1 回答
  • 0 關注
  • 158 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號