windows系统txt文件

input.txt多行合并为一行

package main

import (
	"fmt"
	"io/ioutil"
	"strings"
)

func main() {
	content, err := ioutil.ReadFile("E:\gin_demo\demo30DNF\youhua\input.txt")
	if err != nil {
		fmt.Println("Error reading input file:", err)
		return
	}

	processedContent := strings.ReplaceAll(string(content), "rn", "")

	err = ioutil.WriteFile("E:\gin_demo\demo30DNF\youhua\output.txt", []byte(processedContent), 0644)
	if err != nil {
		fmt.Println("Error writing output file:", err)
		return
	}

	fmt.Println("Successfully removed newlines and saved to output.txt.")
}

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注