如果你真的想包含空格,你可以考虑使用fmt.Scanf()with format %q a double-quoted string safely escaped with Go syntax,例如:package mainimport "fmt"func main() { var s string fmt.Scanf("%q", &s) fmt.Println(s) return}运行它并:$ go run test.go"31 of month"31 of month