We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
package main
import ( "fmt" "os" "os/exec" ) func main() { cmd := exec.Command(`c:\windows\system32\where.exe`, `/f`, "/t", "*.txt") buf, err := cmd.Output() if err != nil { fmt.Println(err) return } var i int var str string fmt.Sscanf(string(buf), `%d 2015/8/23 12:59:38 "%s"`, &i, &str) fmt.Println(i, str) fmt.Fprintf(os.Stdout, "%s", buf) }
运行...
1649 C:\Windows\System32\WindowsCodecsRaw.txt" 1649 2015/8/23 12:59:38 "C:\Windows\System32\WindowsCodecsRaw.txt"
The text was updated successfully, but these errors were encountered:
system: window 10 x64 go version: go1.5.1 windows/amd64
Sorry, something went wrong.
What's the issue?
I think what the OP meant is this program: http://play.golang.org/p/fO2iXLrGUU
fmt.Sscanf(1649 2015/8/23 12:59:38 "C:\Windows\System32\WindowsCodecsRaw.txt", %d 2015/8/23 12:59:38 "%s", &i, &str)
1649 2015/8/23 12:59:38 "C:\Windows\System32\WindowsCodecsRaw.txt"
%d 2015/8/23 12:59:38 "%s"
The scanned str will contain the right double-quote character.
This is working as intended. Scanf %s will keep scanning until it encounters any space characters.
Quote https://golang.org/pkg/fmt ... %s and %v on strings scan a space-delimited token ...
PS: Please ask questions like this on the mailing list. If you use English, golang-nuts, or if you prefer Chinese, golang-china.
No branches or pull requests
package main
运行...
1649 C:\Windows\System32\WindowsCodecsRaw.txt"
1649 2015/8/23 12:59:38 "C:\Windows\System32\WindowsCodecsRaw.txt"
The text was updated successfully, but these errors were encountered: