问题描述
我有这样的字符串
data := `["452","767","406","535","908"]`
我想要这样的输出
452
767
406
535
908
我试试
for _,s := range data {
fmt.Println(s)
}
但结果是
91 34 52 53 50 34 44 34 55 54 55 34 44 34 52 48 54 34 44 34 53 51 53 34 44 34 57 48
解决方法
将其解析为 JSON 字符串。
library(ggmap)
library(ggforce)
library(ggvoronoi)
library(tidyverse)
b <- get_map(c(2.09174,50.52550,7.36819,53.68320),maptype = "toner",source = "stamen",zoom = 8)
lon <- c(3.76779,5.31313,3.48031,3.90727,4.15682)
lat <- c(51.2219,52.0808,50.7684,51.2684,50.9502)
hex_col <- c("#5A586E","#47967F","#4EB22E","#9E82C5","#ADCFAD")
to_plot <- data.frame(lon,lat,hex_col)
ggmap(b,base_layer = ggplot(data = to_plot,aes(x = lon,y = lat))) +
geom_voronoi(mapping = aes(fill = hex_col),alpha = 0.5) +
scale_fill_identity() +
geom_voronoi_segment()
,
package main
import (
"strings"
"unicode"
)
func main() {
data := `["452","767","406","535","908"]`
tokens := strings.FieldsFunc(data,unicode.IsPunct)
for _,token := range tokens {
println(token)
}
}
输出:
452
767
406
535
908