package test import ( "ColdVerify_server/lib" "ColdVerify_server/logs" "fmt" "os/exec" "testing" "time" ) func TestBeego(t *testing.T) { formatTimeStr := "2022-05-25 18:58" formatTime, err := time.Parse("2006-01-02 15:04", formatTimeStr) if err != nil { logs.Error(lib.FuncName(), err) } logs.Println("formatTime", formatTime) //打印结果:2017-04-11 13:33:37 +0000 UTC //// Read from docx file //r, err := docx.ReadDocxFile("./template.docx") //// Or read from memory //// r, err := docx.ReadDocxFromMemory(data io.ReaderAt, size int64) // //// Or read from a filesystem object: //// r, err := docx.ReadDocxFromFS(file string, fs fs.FS) // //if err != nil { // panic(err) //} //docx1 := r.Editable() //// Replace like https://golang.org/pkg/strings/#Replace //docx1.Replace("old_1_1", "new_1_1", -1) //docx1.Replace("old_1_2", "new_1_2", -1) ////docx1.ReplaceLink("http://example.com/", "https://github.com/nguyenthenguyen/docx", 1) ////docx1.ReplaceHeader("out with the old", "in with the new") ////docx1.ReplaceFooter("Change This Footer", "new footer") //docx1.WriteToFile("./new_result_1.docx") // //docx2 := r.Editable() //docx2.Replace("old_2_1", "new_2_1", -1) //docx2.Replace("old_2_2", "new_2_2", -1) //docx2.WriteToFile("./new_result_2.docx") //// Or write to ioWriter //// docx2.Write(ioWriter io.Writer) //docx3 := r.Editable() ////Currently only swaps apples for apples i.e. png to png, and not png to jpeg etc. ////d.ReplaceImage("word/media/image1.png", "./new.png") //docx3.WriteToFile("./new_result_3.docx") } func TestR(t *testing.T) { // 设置要执行的Python脚本和参数 scriptPath := "../script" arg1 := "/Users/zoie/work/study/python/project/python2wordpdf_process-master/input.pdf" arg2 := "../ofile/watermarked.pdf" arg3 := "../script/watermark.pdf" // 执行Python脚本 cmd := exec.Command("python", "add_watermark.py", arg1, arg2, arg3) cmd.Dir = scriptPath // 获取命令输出 output, err := cmd.CombinedOutput() if err != nil { fmt.Println("Error:", err) //return } // 打印Python脚本的输出 fmt.Println(string(output)) }