解决方案3 :
bytes := []rune(str)
for from , to := 0 , len(bytes) -1 ; from < to ; from , to = from + 1, to -1{
bytes[from] , bytes[to] = bytes[to] , bytes[from]
}
str = string(bytes)
return str
解决方案2不能转换中文字符的问题:
解决方案3 :
bytes := []rune(str)
for from , to := 0 , len(bytes) -1 ; from < to ; from , to = from + 1, to -1{
bytes[from] , bytes[to] = bytes[to] , bytes[from]
}
str = string(bytes)
return str
解决方案2不能转换中文字符的问题: