“Golang String para bytes” Respostas de código

Golang String para bytes

hello := []byte("hello-world")
Friendly Fox

Vá String to Byte Array

b := []byte("ABC€")
s := string([]byte{65, 66, 67, 226, 130, 172})
Zealous Zebra

Golang [] byte para cordas

s := string([]byte{65, 66, 67, 226, 130, 172})
fmt.Println(s) // ABC€
Worrisome Wasp

Golang converte string em bytes e converte bytes para string

package main
 
import (
    "fmt"
)
 
func main() {
    var s string = "Hello World"
    sb := []byte(s)
     
    fmt.Println(sb)  // [72 101 108 108 111 32 87 111 114 108 100]
     
    fmt.Println(string(sb)) // Hello World
}
Grieving Gaur

Respostas semelhantes a “Golang String para bytes”

Perguntas semelhantes a “Golang String para bytes”

Procure respostas de código populares por idioma

Procurar outros idiomas de código