草庐IT

ChangeStatus

全部标签

arrays - 如何在结构数组中映射文本文件内容?

我有一个文本文件data.txt:0,0123,"Value1"1,0456,"Value2"在Go中我定义了结构体:typeChangeStatusstruct{Nr1stringNr2stringCategorystring}我是Go的新手,所以我想知道如何读取该文本文件并将每个文本文件行放入ChangeStatus数组中? 最佳答案 你可以使用csv.Reader为此,example:funcmain(){status:=[]ChangeStatus{}f:=strings.NewReader(text_file)//repl

arrays - 如何在结构数组中映射文本文件内容?

我有一个文本文件data.txt:0,0123,"Value1"1,0456,"Value2"在Go中我定义了结构体:typeChangeStatusstruct{Nr1stringNr2stringCategorystring}我是Go的新手,所以我想知道如何读取该文本文件并将每个文本文件行放入ChangeStatus数组中? 最佳答案 你可以使用csv.Reader为此,example:funcmain(){status:=[]ChangeStatus{}f:=strings.NewReader(text_file)//repl