1. 首页
  2. 主题
  3. Go问与答

为什么 int() 无法转变 "" 双引号 类型的 字符串 数字

lishuailw · · 3073 次点击
```go package main import "fmt" func main() { //strconv,'1',我知道能转换,但是双引号就不行 a:="1" b:=int(a) fmt.Printf("%v\n",b) } ``` 结果是: ```go # command-line-arguments .03円.go:8:8: cannot convert a (type string) to type int Compilation finished with exit code 2 ```
单引号是数字。 你试试但引号里包两个字符就知道了
#2
更多评论
单引号其实是rune,int是不能转换字符串的
#1

用户登录

没有账号?注册

今日阅读排行

    加载中

一周阅读排行

    加载中