str := make([]byte, 0, 100) str = strconv.AppendInt(str, 123, 10) // 10用来表示进制, 此处为10进制 str = strconv.AppendBool(str, false) str = strconv.AppendQuote(str, "andrew") str = strconv.AppendQuoteRune(str, '刘') fmt.Println(string(str)) // 123false"andrew"'刘' s := strconv.FormatBool(true) fmt.Printf("%T, %v\n", s, s) // string, true v := 3.1415926535 s32 := strconv.FormatFloat(v, 'E', -1, 32) fmt.Printf("%T, %v\n", s32, s32) // string, 3.1415927E+00 s10 := strconv.FormatInt(-44, 10) fmt.Printf("%T, %v\n", s10, s10) // string, -44 num := strconv.Itoa(1234) fmt.Printf("%T, %v\n", s, s) // int, 1023 fmt.Printf("%T, %v\n", num, num) // string, 1234
|