【问题标题】:Is this due to https encoding?这是由于https编码吗?
【发布时间】:2021-02-15 14:57:17
【问题描述】:

我是开发 https 网站的新手,遇到以下问题。我要求网站简单地返回 shell 命令“pwd”的产品

在Go中,相关行如下:

            import (
               "os/exec"
            )

            out, err := exec.Command("pwd").Output()
            if err != nil {
                fmt.Println(err)
            }
            fmt.Println(out)

响应似乎已编码。

            [47 109 110 116 47 100 47 98 105 110 47 100 101 118 101 108 111 112 109 101 110 116 47 119 119 119 10]

问题:如何检索实际值?

【问题讨论】:

  • 输出是一个字节数组。使用fmt.Println(string(out)) 打印
  • @Burak Serdar,谢谢!!如何将您的答案标记为正确?
  • 这是实际值。

标签: go https


【解决方案1】:

这与 https 编码无关。 Command 返回一个 []byte,然后您可以继续打印。

如果你想要输出的字符串表示,你必须转换它:

fmt.Println(string(out))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多