为了账号安全,请及时绑定邮箱和手机立即绑定

go request包发送请求后,返回编码出现乱码?

go request包发送请求后,返回编码出现乱码?

Go
哔哔one 2018-08-31 22:18:40
// testpackage mainimport (    "io/ioutil"    "net/http"    "os"    "github.com/mozillazg/request")func main() {    c := &http.Client{}    req := request.NewRequest(c)    resp, _ := req.Get("http://segmentfault.com/")    defer resp.Body.Close() // **Don't forget close the response body**    body, _ := ioutil.ReadAll(resp.Body)    fr, _ := os.Create("request.html")    fr.Write(body)    res, _ := http.Get("http://segmentfault.com/")    truebody, _ := ioutil.ReadAll(res.Body)    res.Body.Close()    ft, _ := os.Create("get.html")    ft.Write(truebody)}request包请求结果http.get请求输出结果出现乱码 而这返回的不都是response 对象吗 怎么一个乱码 一个正常,,求解决
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 2562 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信