Go类型转换

类型转换意味着将变量从一种数据类型转换为另一种数据类型。当大字体转换为小字体时, 该值可能会丢失。

转到类型转换示例

package main
import (
   "fmt"
   "strconv"
)
func main() {

   var i int = 10
   var f float64 = 6.44
   var str1 string = "101"
   var str2 string = "10.123"

   fmt.Println(float64(i))
   fmt.Println(int(f))

   newInt, _ := strconv.ParseInt(str1, 0, 64)
   fmt.Println(newInt)

   newfloat, _ := strconv.ParseFloat(str2, 64)
   fmt.Println(newfloat)
}

输出:

10
6
101
10.123
微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_50020.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?