go的一个for中的print

    str3 := "chinese:日本語"
    fmt.Println("index int(rune) rune    char bytes")
    for index, rune_ := range str3 {
        fmt.Printf("%-2d      %d      %U '%c' % x\n", index, rune_, rune_, rune_, []byte(string(rune_)))
    }
    str := "G"
    for i := 1; i <= 25; i++ {
        print(str)
        str += "G"
    }

输出

index int(rune) rune    char bytes
GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG0       99      U+0063 'c' 63
1       104      U+0068 'h' 68
2       105      U+0069 'i' 69
3       110      U+006E 'n' 6e
4       101      U+0065 'e' 65
5       115      U+0073 's' 73
6       101      U+0065 'e' 65
7       58      U+003A ':' 3a
8       26085      U+65E5 '日' e6 97 a5
11      26412      U+672C '本' e6 9c ac
14      35486      U+8A9E '語' e8 aa 9e

G那行会变动行号

阅读 2.8k
4 个回答

你是go run 运行的?还是在idea下面?

新手上路,请多包涵

....cczcxc

print函数造成...

新手上路,请多包涵

试了一下,在goland里面运行的话,是会出现这个问题,如果是build之后运行或者直接go run,都不会出现,可能是因为输出方式不一样造成的.
print()函数是输出到标准错误流中并打印,而你调用的fmt包中的输出是输出到标准输出

clipboard.png

clipboard.png

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏