<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # package strconv `import "strconv"` strconv包實現了基本數據類型和其字符串表示的相互轉換。 ## Index * [Constants](#pkg-constants) * [Variables](#pkg-variables) * [type NumError](#NumError) * [func (e \*NumError) Error() string](#NumError.Error) * [func IsPrint(r rune) bool](#IsPrint) * [func CanBackquote(s string) bool](#CanBackquote) * [func Quote(s string) string](#Quote) * [func QuoteToASCII(s string) string](#QuoteToASCII) * [func QuoteRune(r rune) string](#QuoteRune) * [func QuoteRuneToASCII(r rune) string](#QuoteRuneToASCII) * [func Unquote(s string) (t string, err error)](#Unquote) * [func UnquoteChar(s string, quote byte) (value rune, multibyte bool, tail string, err error)](#UnquoteChar) * [func ParseBool(str string) (value bool, err error)](#ParseBool) * [func ParseInt(s string, base int, bitSize int) (i int64, err error)](#ParseInt) * [func ParseUint(s string, base int, bitSize int) (n uint64, err error)](#ParseUint) * [func ParseFloat(s string, bitSize int) (f float64, err error)](#ParseFloat) * [func FormatBool(b bool) string](#FormatBool) * [func FormatInt(i int64, base int) string](#FormatInt) * [func FormatUint(i uint64, base int) string](#FormatUint) * [func FormatFloat(f float64, fmt byte, prec, bitSize int) string](#FormatFloat) * [func Atoi(s string) (i int, err error)](#Atoi) * [func Itoa(i int) string](#Itoa) * [func AppendBool(dst []byte, b bool) []byte](#AppendBool) * [func AppendInt(dst []byte, i int64, base int) []byte](#AppendInt) * [func AppendUint(dst []byte, i uint64, base int) []byte](#AppendUint) * [func AppendFloat(dst []byte, f float64, fmt byte, prec int, bitSize int) []byte](#AppendFloat) * [func AppendQuote(dst []byte, s string) []byte](#AppendQuote) * [func AppendQuoteToASCII(dst []byte, s string) []byte](#AppendQuoteToASCII) * [func AppendQuoteRune(dst []byte, r rune) []byte](#AppendQuoteRune) * [func AppendQuoteRuneToASCII(dst []byte, r rune) []byte](#AppendQuoteRuneToASCII) ### Examples * [Unquote](#example-Unquote) ## Constants ``` const IntSize = intSize ``` IntSize是int或uint類型的字位數。 ## Variables ``` var ErrRange = errors.New("value out of range") ``` ErrRange表示超出目標類型表示范圍。 ``` var ErrSyntax = errors.New("invalid syntax") ``` ErrSyntax表示不符合目標類型語法。 ## type [NumError](https://github.com/golang/go/blob/master/src/strconv/atoi.go#L16 "View Source") ``` type NumError struct { Func string // 失敗的函數(ParseBool、ParseInt、ParseUint、ParseFloat) Num string // 輸入的字符串 Err error // 失敗的原因(ErrRange、ErrSyntax) } ``` NumError表示一次失敗的轉換。 ### func (\*NumError) [Error](https://github.com/golang/go/blob/master/src/strconv/atoi.go#L22 "View Source") ``` func (e *NumError) Error() string ``` ## func [IsPrint](https://github.com/golang/go/blob/master/src/strconv/quote.go#L402 "View Source") ``` func IsPrint(r rune) bool ``` 返回一個字符是否是可打印的,和unicode.IsPrint一樣,r必須是:字母(廣義)、數字、標點、符號、ASCII空格。 ## func [CanBackquote](https://github.com/golang/go/blob/master/src/strconv/quote.go#L145 "View Source") ``` func CanBackquote(s string) bool ``` 返回字符串s是否可以不被修改的表示為一個單行的、沒有空格和tab之外控制字符的反引號字符串。 ## func [Quote](https://github.com/golang/go/blob/master/src/strconv/quote.go#L90 "View Source") ``` func Quote(s string) string ``` 返回字符串s在go語法下的雙引號字面值表示,控制字符、不可打印字符會進行轉義。(如\t,\n,\xFF,\u0100) ## func [QuoteToASCII](https://github.com/golang/go/blob/master/src/strconv/quote.go#L103 "View Source") ``` func QuoteToASCII(s string) string ``` 返回字符串s在go語法下的雙引號字面值表示,控制字符和不可打印字符、非ASCII字符會進行轉義。 ## func [QuoteRune](https://github.com/golang/go/blob/master/src/strconv/quote.go#L116 "View Source") ``` func QuoteRune(r rune) string ``` 返回字符r在go語法下的單引號字面值表示,控制字符、不可打印字符會進行轉義。(如\t,\n,\xFF,\u0100) ## func [QuoteRuneToASCII](https://github.com/golang/go/blob/master/src/strconv/quote.go#L131 "View Source") ``` func QuoteRuneToASCII(r rune) string ``` 返回字符r在go語法下的單引號字面值表示,控制字符、不可打印字符、非ASCII字符會進行轉義。 ## func [Unquote](https://github.com/golang/go/blob/master/src/strconv/quote.go#L294 "View Source") ``` func Unquote(s string) (t string, err error) ``` 函數假設s是一個單引號、雙引號、反引號包圍的go語法字符串,解析它并返回它表示的值。(如果是單引號括起來的,函數會認為s是go字符字面值,返回一個單字符的字符串) Example ``` test := func(s string) { t, err := strconv.Unquote(s) if err != nil { fmt.Printf("Unquote(%#v): %v\n", s, err) } else { fmt.Printf("Unquote(%#v) = %v\n", s, t) } } s := `cafe\u0301` // If the string doesn't have quotes, it can't be unquoted. test(s) // invalid syntax test("`" + s + "`") test(`"` + s + `"`) test(`'\u00e9'`) ``` Output: ``` Unquote("cafe\\u0301"): invalid syntax Unquote("`cafe\\u0301`") = cafe\u0301 Unquote("\"cafe\\u0301\"") = café Unquote("'\\u00e9'") = é ``` ## func [UnquoteChar](https://github.com/golang/go/blob/master/src/strconv/quote.go#L182 "View Source") ``` func UnquoteChar(s string, quote byte) (value rune, multibyte bool, tail string, err error) ``` 函數假設s是一個表示字符的go語法字符串,解析它并返回四個值: ``` 1) value,表示一個rune值或者一個byte值 2) multibyte,表示value是否是一個多字節的utf-8字符 3) tail,表示字符串剩余的部分 4) err,表示可能存在的語法錯誤 ``` quote參數為單引號時,函數認為單引號是語法字符,不接受未轉義的單引號;雙引號時,函數認為雙引號是語法字符,不接受未轉義的雙引號;如果是零值,函數把單引號和雙引號當成普通字符。 ## func [ParseBool](https://github.com/golang/go/blob/master/src/strconv/atob.go#L10 "View Source") ``` func ParseBool(str string) (value bool, err error) ``` 返回字符串表示的bool值。它接受1、0、t、f、T、F、true、false、True、False、TRUE、FALSE;否則返回錯誤。 ## func [ParseInt](https://github.com/golang/go/blob/master/src/strconv/atoi.go#L150 "View Source") ``` func ParseInt(s string, base int, bitSize int) (i int64, err error) ``` 返回字符串表示的整數值,接受正負號。 base指定進制(2到36),如果base為0,則會從字符串前置判斷,"0x"是16進制,"0"是8進制,否則是10進制; bitSize指定結果必須能無溢出賦值的整數類型,0、8、16、32、64?分別代表?int、int8、int16、int32、int64;返回的err是\*NumErr類型的,如果語法有誤,err.Error = ErrSyntax;如果結果超出類型范圍err.Error = ErrRange。 ## func [ParseUint](https://github.com/golang/go/blob/master/src/strconv/atoi.go#L48 "View Source") ``` func ParseUint(s string, base int, bitSize int) (n uint64, err error) ``` ParseUint類似ParseInt但不接受正負號,用于無符號整型。 ## func [ParseFloat](https://github.com/golang/go/blob/master/src/strconv/atof.go#L533 "View Source") ``` func ParseFloat(s string, bitSize int) (f float64, err error) ``` 解析一個表示浮點數的字符串并返回其值。 如果s合乎語法規則,函數會返回最為接近s表示值的一個浮點數(使用IEEE754規范舍入)。bitSize指定了期望的接收類型,32是float32(返回值可以不改變精確值的賦值給float32),64是float64;返回值err是\*NumErr類型的,語法有誤的,err.Error=ErrSyntax;結果超出表示范圍的,返回值f為±Inf,err.Error= ErrRange。 ## func [FormatBool](https://github.com/golang/go/blob/master/src/strconv/atob.go#L21 "View Source") ``` func FormatBool(b bool) string ``` 根據b的值返回"true"或"false"。 ## func [FormatInt](https://github.com/golang/go/blob/master/src/strconv/itoa.go#L18 "View Source") ``` func FormatInt(i int64, base int) string ``` 返回i的base進制的字符串表示。base?必須在2到36之間,結果中會使用小寫字母'a'到'z'表示大于10的數字。 ## func [FormatUint](https://github.com/golang/go/blob/master/src/strconv/itoa.go#L10 "View Source") ``` func FormatUint(i uint64, base int) string ``` 是FormatInt的無符號整數版本。 ## func [FormatFloat](https://github.com/golang/go/blob/master/src/strconv/ftoa.go#L44 "View Source") ``` func FormatFloat(f float64, fmt byte, prec, bitSize int) string ``` 函數將浮點數表示為字符串并返回。 bitSize表示f的來源類型(32:float32、64:float64),會據此進行舍入。 fmt表示格式:'f'(-ddd.dddd)、'b'(-ddddp±ddd,指數為二進制)、'e'(-d.dddde±dd,十進制指數)、'E'(-d.ddddE±dd,十進制指數)、'g'(指數很大時用'e'格式,否則'f'格式)、'G'(指數很大時用'E'格式,否則'f'格式)。 prec控制精度(排除指數部分):對'f'、'e'、'E',它表示小數點后的數字個數;對'g'、'G',它控制總的數字個數。如果prec?為-1,則代表使用最少數量的、但又必需的數字來表示f。 ## func [Atoi](https://github.com/golang/go/blob/master/src/strconv/atoi.go#L195 "View Source") ``` func Atoi(s string) (i int, err error) ``` Atoi是ParseInt(s, 10, 0)的簡寫。 ## func [Itoa](https://github.com/golang/go/blob/master/src/strconv/itoa.go#L24 "View Source") ``` func Itoa(i int) string ``` Itoa是FormatInt(i, 10)?的簡寫。 ## func [AppendBool](https://github.com/golang/go/blob/master/src/strconv/atob.go#L30 "View Source") ``` func AppendBool(dst []byte, b bool) []byte ``` 等價于append(dst, FormatBool(b)...) ## func [AppendInt](https://github.com/golang/go/blob/master/src/strconv/itoa.go#L30 "View Source") ``` func AppendInt(dst []byte, i int64, base int) []byte ``` 等價于append(dst, FormatInt(I, base)...) ## func [AppendUint](https://github.com/golang/go/blob/master/src/strconv/itoa.go#L37 "View Source") ``` func AppendUint(dst []byte, i uint64, base int) []byte ``` 等價于append(dst, FormatUint(I, base)...) ## func [AppendFloat](https://github.com/golang/go/blob/master/src/strconv/ftoa.go#L50 "View Source") ``` func AppendFloat(dst []byte, f float64, fmt byte, prec int, bitSize int) []byte ``` 等價于append(dst, FormatFloat(f, fmt, prec, bitSize)...) ## func [AppendQuote](https://github.com/golang/go/blob/master/src/strconv/quote.go#L96 "View Source") ``` func AppendQuote(dst []byte, s string) []byte ``` 等價于append(dst, Quote(s)...) ## func [AppendQuoteToASCII](https://github.com/golang/go/blob/master/src/strconv/quote.go#L109 "View Source") ``` func AppendQuoteToASCII(dst []byte, s string) []byte ``` 等價于append(dst, QuoteToASCII(s)...) ## func [AppendQuoteRune](https://github.com/golang/go/blob/master/src/strconv/quote.go#L123 "View Source") ``` func AppendQuoteRune(dst []byte, r rune) []byte ``` 等價于append(dst, QuoteRune(r)...) ## func [AppendQuoteRuneToASCII](https://github.com/golang/go/blob/master/src/strconv/quote.go#L138 "View Source") ``` func AppendQuoteRuneToASCII(dst []byte, r rune) []byte ``` 等價于append(dst, QuoteRuneToASCII(r)...)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看