GO 反转字符串
GO 反转字符串
package main
import "fmt"
func main() {
str := "hello,world"
bytes := []byte(str)
lenBytes := len(bytes)
forLen := lenBytes / 2
for i := 0; i < forLen; i++ {
bytes[i], bytes[lenBytes-i-1] = bytes[lenBytes-i-1], bytes[i]
}
fmt.Println(string(bytes))
}

浙公网安备 33010602011771号