摘要: 在Go中字符串是不可变的,例如下面的代码编译时会报错:cannot assign to s[0] var s string = "hello" s[0] = 'c' 但如果真的想要修改怎么办呢?下面的代码可以实现: s := "hello" c := []byte(s) // 将字符串 s 转换为 []byte 类型 c[0] = 'c' s2 := string(c) // 再转换... 阅读全文
posted @ 2019-01-21 21:16 anobscureretreat 阅读(559) 评论(0) 推荐(0)
摘要: s := "hello," m := " world" a := s + m fmt.Printf("%s\n", a) 阅读全文
posted @ 2019-01-21 21:15 anobscureretreat 阅读(137) 评论(0) 推荐(0)
摘要: 输出 阅读全文
posted @ 2019-01-21 20:21 anobscureretreat 阅读(436) 评论(0) 推荐(0)
摘要: 输出 阅读全文
posted @ 2019-01-21 20:19 anobscureretreat 阅读(2051) 评论(0) 推荐(0)
摘要: 输出 阅读全文
posted @ 2019-01-21 19:31 anobscureretreat 阅读(255) 评论(0) 推荐(0)