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代码仅打印一次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'}`
白猪掌柜的
ibeautiful
湖上湖
相关分类