字符串
str:="hello"
c:=[]byte(str)
c[0]='c'
s2:= string(c) // s2 == "cello"substr := str[n:m]// gives only the bytes:
for i:=0; i < len(str); i++ {
… = str[i]
}
// gives the Unicode characters:
for ix, ch := range str {
…
}链接
Last updated
str:="hello"
c:=[]byte(str)
c[0]='c'
s2:= string(c) // s2 == "cello"substr := str[n:m]// gives only the bytes:
for i:=0; i < len(str); i++ {
… = str[i]
}
// gives the Unicode characters:
for ix, ch := range str {
…
}Last updated
str1 := "Hello "
str2 := "World!"
str1 += str2 //str1 == "Hello World!"