4. Convert between byte array/slice and string
페이지 정보
작성자 관리자 댓글 0건 조회 2,983회 작성일 19-05-17 07:44본문
4. Convert between byte array/slice and string
Convert string to bytes
When you convert a string to a byte slice, you get a new slice that contains the same bytes as the string.
b := []byte("ABC€")
fmt.Println(b) // [65 66 67 226 130 172]
Convert bytes to string
When you convert a slice of bytes to a string, you get a new string that contains the same bytes as the slice.
s := string([]byte{65, 66, 67, 226, 130, 172})
fmt.Println(s) // ABC€
댓글목록
등록된 댓글이 없습니다.