GO語言"math/big"包中"Rat.Scan"類型的用法及代碼示例。
用法:
func(z *Rat) Scan(s fmt.ScanState, ch rune) error
Scan 是 fmt.Scanner 的支持例程。它接受格式'e'、'E'、'f'、'F'、'g'、'G'和'v'。所有格式都是等效的。
例子:
package main
import (
"fmt"
"log"
"math/big"
)
func main() {
// The Scan function is rarely used directly;
// the fmt package recognizes it as an implementation of fmt.Scanner.
r := new(big.Rat)
_, err := fmt.Sscan("1.5000", r)
if err != nil {
log.Println("error scanning value:", err)
} else {
fmt.Println(r)
}
}
輸出:
3/2
相關用法
- GO Rat.SetString用法及代碼示例
- GO RawMessage用法及代碼示例
- GO Regexp.FindString用法及代碼示例
- GO Regexp.FindAllIndex用法及代碼示例
- GO ResponseRecorder用法及代碼示例
- GO ReverseBytes64用法及代碼示例
- GO ReverseBytes16用法及代碼示例
- GO Regexp.ReplaceAllLiteralString用法及代碼示例
- GO Regexp.FindStringSubmatch用法及代碼示例
- GO Rows用法及代碼示例
- GO Regexp.FindAllString用法及代碼示例
- GO ReadMessage用法及代碼示例
- GO Regexp.ExpandString用法及代碼示例
- GO ResponseWriter用法及代碼示例
- GO Regexp.FindAllStringSubmatch用法及代碼示例
- GO Reverse用法及代碼示例
- GO Read用法及代碼示例
- GO RotateLeft32用法及代碼示例
- GO RuneCount用法及代碼示例
- GO Rel用法及代碼示例
注:本文由純淨天空篩選整理自golang.google.cn大神的英文原創作品 Rat.Scan。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。