Go 언어

본문 바로가기
사이트 내 전체검색


Go 언어
Go 언어

4. Convert between byte array/slice and string

페이지 정보

작성자 관리자 댓글 0건 조회 2,315회 작성일 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€


댓글목록

등록된 댓글이 없습니다.


개인정보취급방침 서비스이용약관 모바일 버전으로 보기 상단으로

TEL. 063-469-4551 FAX. 063-469-4560 전북 군산시 대학로 558
군산대학교 컴퓨터정보공학과

Copyright © www.leelab.co.kr. All rights reserved.