gpt4 book ai didi

python - Go 等效于 Python 中的 decode ('hex' )

转载 作者:IT王子 更新时间:2023-10-29 01:44:34 25 4
gpt4 key购买 nike

我正在努力将现有的 Python 库转换为 Go,但我被挂断了。

是否有等同于以下 Python 代码的 go?

test = "ec033aa702"
test.decode('hex')

我一直在阅读,但似乎找不到我要找的东西。

最佳答案

这对你有用吗?

package main

import (
"encoding/hex"
"fmt"
"log"
)

func main() {
const s = "ec033aa702"
decoded, err := hex.DecodeString(s)
if err != nil {
log.Fatal(err)
}

fmt.Printf("%s\n", decoded)
}

DecodeString

Try it online!

关于python - Go 等效于 Python 中的 decode ('hex' ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46760712/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com