douzhen9428
2017-08-12 02:15
浏览 344
已采纳

fmt.Println打印出%s之类的格式动词

I've written code that is intended to print out keys and values in a map.

kvs := map[string]string{"a": "apple", "b": "banana"}
for k, v := range kvs {
    fmt.Println("%s -> %s
", k, v)
}

I'm expecting the output to be:

a -> apple
b -> banana

But the output is actually:

%s -> %s
a apple
%s -> %s
b banana
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题