out.txt文件:
"WIN","\Microsoft\Windows\AppID\PolicyConverter","Disabled","","Interactive/Background","N/A","1","Microsoft Corporation","%windir%\system32\appidpolicyconverter.exe ","N/A","将软件限制策略从 XML 格式转换为二进制格式。"
原字符:
![image.png](https://static.studygolang.com/220108/f116d818b1b3b55b1b58e5a76c6b35ca.png)
读取字符后,写入文件变成如下图了
![image.png](https://static.studygolang.com/220108/bc194c2775a84fef60228b1e8c387722.png)
代码:
package main
import (
"bufio"
"fmt"
"io"
"io/ioutil"
"os"
"strings"
)
func gotest() {
newfile, _ := os.Open("./out.txt")
defer newfile.Close()
str := bufio.NewReader(newfile)
array := []string{}
for {
strline, _, err := str.ReadLine()
if err == io.EOF {
break
}
array = append(array, string(strline))
}
acc := ""
for _, str := range array {
array := strings.Split(str, "\",\"")
acc += fmt.Sprintf(array[1] + "\t" + array[8] + "\t" + array[10] + "\n")
}
ioutil.WriteFile("tmp.txt", []byte(acc), 0666)
}
有疑问加站长微信联系(非本文作者)