#我不明白当与 一起使用时的含义q。
fmt.Printf("%q", "\"")
fmt.Println()
fmt.Printf("%#q", "\"")
Run Code Online (Sandbox Code Playgroud)
印刷
"\""
`"`
Run Code Online (Sandbox Code Playgroud)
但
"\""
`"`
Run Code Online (Sandbox Code Playgroud)
印刷
"\n"
"\n"
Run Code Online (Sandbox Code Playgroud)
https://cs.opensource.google/go/go/+/master:src/fmt/fmt_test.go有更多示例。
fmt.Printf("%q", "\n")
fmt.Println()
fmt.Printf("%#q", "\n")
Run Code Online (Sandbox Code Playgroud)