当前位置:网站首页>2022-08-05:以下go语言代码输出什么?A:65, string;B:A, string;C:65, int;D:报错。 package main i
2022-08-05:以下go语言代码输出什么?A:65, string;B:A, string;C:65, int;D:报错。 package main i
2022-08-05 22:51:00 【福大大架构师每日一题】
2022-08-05:以下go语言代码输出什么?A:65, string;B:A, string;C:65, int;D:报错。
package main
import (
"fmt"
)
func main() {
num := 65
str := string(num)
fmt.Printf("%v, %T\n", str, str)
}答案2022-08-05:
这道题有选A的,也有选D的。但正确答案选B。不过,如果你使用 go vet 检查,会提示:conversion from int to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?)。
也就是说,如果要将数字 65 转为字符串,不能使用 string(num),如果使用这种方式转,得到的是一个 rune 的字符串表示,因为字面 A 的 ASCII 码是 65,因此这里输出结果是 A,string。
边栏推荐
- 以小窥大:IO 卡顿探寻苹果文件系统
- 计数排序(Counting Sort)
- 有关CRT密码反编译问题
- OCCT示例学习笔记3--Modeling项目
- Peeking into the Big from the Small: IO Caton Explores Apple's File System
- LeetCode高频题76. 最小覆盖子串:欠账还债还款问题,子串考虑i开头的情况所有答案更新一波
- [debian]cockpit error Cannot refresh cache whilst offline
- 七夕节最深情表白文案从此告别搓衣板
- CAN-Oe channel configuration method
- MUI底部菜单栏 uniapp 底部菜单栏
猜你喜欢

宝塔实测-电商ERP进销存系统源码

如何在面试中介绍自己的项目经验

Pagoda measurement - e-commerce ERP invoicing system source code

代码越写越乱?那是因为你没用责任链!

About Invalid prop: type check failed for prop “index“. Expected String, got Undefined

ESXI7.0主机安装群晖DS3617xs

How to write a student information management system using C language code

国内BLDC电机控制方案目前存在什么痛点?

Application of MES and APS in Food Processing Industry

视觉slam学习|基础篇02
随机推荐
C language basic walkthrough(9)
ARC142F
[ESP32] ESP8266 is connected to Xiao Ai to control relay 2
过孔设计得越小就越好吗?
关于 Invalid prop: type check failed for prop “index“. Expected String, got Undefined
【flask】模块拆分の使用红图
CAN-Oe channel configuration method
[frp] Raspberry Pi uses Frp intranet penetration access
Day11:二叉树---->满~、完全~、堆
【TypeScript】什么是字面量类型、类型推断、类型拓宽和类型缩小?
Nanoprobes Nanogold标签:助力显示SAP-1 的分布和功能
How to add custom syntax to MySQL
NVM quick installation tutorial, only one
Basic use of CardView, DrawerLayout sliding menu, Fragment
Pagoda measurement - e-commerce ERP invoicing system source code
Lean Manufacturing MES Manufacturing Execution System
2022-8-5 第六组 ptz 集合与树
使用MQ的时候,怎么确保消息100%不丢失?
IDEA中如何使用debug调试项目 一步一步详细教程
手机照片备份方案Immich