首页 > 其他分享 >0130-Go-数值解析

0130-Go-数值解析

时间:2022-11-28 22:36:19浏览次数:68  
标签:0130 fmt strconv Println 64 Go 解析

环境

  • Time 2022-08-25
  • Go 1.19

前言

说明

参考:https://gobyexample.com/number-parsing

目标

使用 Go 语言的数值解析。

示例

package main

import (
    "fmt"
    "strconv"
)

func main() {

    f, _ := strconv.ParseFloat("1.234", 64)
    fmt.Println(f)

    i, _ := strconv.ParseInt("123", 0, 64)
    fmt.Println(i)

    d, _ := strconv.ParseInt("0x1c8", 0, 64)
    fmt.Println(d)

    u, _ := strconv.ParseUint("789", 0, 64)
    fmt.Println(u)

    k, _ := strconv.Atoi("135")
    fmt.Println(k)

    _, e := strconv.Atoi("wat")
    fmt.Println(e)
}

总结

使用 Go 语言的数值解析。

附录

标签:0130,fmt,strconv,Println,64,Go,解析
From: https://www.cnblogs.com/jiangbo4444/p/16933869.html

相关文章

  • 0129-Go-随机数
    环境Time2022-08-25Go1.19前言说明参考:https://gobyexample.com/random-numbers目标使用Go语言的随机数。示例packagemainimport("fmt""math......
  • 0131-Go-URL 解析
    环境Time2022-08-25Go1.19前言说明参考:https://gobyexample.com/url-parsing目标使用Go语言的URL解析。示例packagemainimport("fmt""net"......
  • 0132-Go-SHA256
    环境Time2022-08-25Go1.19前言说明参考:https://gobyexample.com/sha256-hashes目标使用Go语言的SHA256。示例packagemainimport("crypto/sha256"......
  • 0133-Go-Base64
    环境Time2022-08-25Go1.19前言说明参考:https://gobyexample.com/base64-encoding目标使用Go语言的Base64。示例packagemainimport(b64"encoding......
  • 0121-Go-字符串格式化
    环境Time2022-08-25Go1.19前言说明参考:https://gobyexample.com/string-formatting目标使用Go语言的字符串格式化。示例packagemainimport("fmt"......
  • 0120-Go-字符串函数
    环境Time2022-08-25Go1.19前言说明参考:https://gobyexample.com/string-functions目标使用Go语言的字符串函数。示例packagemainimport("fmt"......
  • 0122-Go-模板字符串
    环境Time2022-08-25Go1.19前言说明参考:https://gobyexample.com/text-templates目标使用Go语言的模板字符串。示例packagemainimport("os""t......
  • 0123-Go-正则表达式
    环境Time2022-08-25Go1.19前言说明参考:https://gobyexample.com/regular-expressions目标使用Go语言的正则表达式。示例packagemainimport( "bytes" ......
  • 0124-Go-JSON 转换
    环境Time2022-08-25Go1.19前言说明参考:https://gobyexample.com/json目标使用Go语言的JSON。简单值packagemainimport("encoding/json""fmt......
  • 0125-Go-XML 转换
    环境Time2022-08-25Go1.19前言说明参考:https://gobyexample.com/xml目标使用Go语言的XML。示例packagemainimport("encoding/xml""fmt")......