package main
import "fmt"
func main(){
sample := map[string]string{
"key1":"value1",
"key2":"value2",
"key3":"value3",
}
for i := 0;i<3;i++{
fmt.Println(sample)
}
}
上面的 go 代码只打印了 3 次 map[string]string。
我希望它是一个固定的输出,但它显示如下:
map[key3:value3 key2:value2 key1:value1]
map[key1:value1 key3:value3 key2:value2]
map[key2:value2 key1:value1 key3:value3]
它因人而异!
在 python 中:
#!/bin/env python
#encoding=utf8
sample = {
"key1":"value1",
"key2":"value2",
"key3":"value3",
}
for i in range(3):
print sample
输出:
{'key3': 'value3', 'key2': 'value2', 'key1': 'value1'}
{'key3': 'value3', 'key2': 'value2', 'key1': 'value1'}
{'key3': 'value3', 'key2': 'value2', 'key1': 'value1'}`