go - go中符文文字中的多个字符
问题描述
我是新来的。我的问题是得到奇数。但我得到这个错误。我不知道你能解释一下我犯了什么错误吗?
package main
import "fmt"
func main(){
var a int
fmt.Printf("Enter the number : ")
fmt.Scanf('%d', &a)
if a % 2==0{
fmt.Println(" %d Is even number", a)
}else{
fmt.Println( "%d is odd number", a)
}
}
解决方案
更改'%d'
为"%d"
。
在 Go中,单引号用于符文文字。
'a'
'ä'
'本'
'\t'
'\000'
'\007'
'\377'
'\x07'
'\xff'
'\u12e4'
'\U00101234'
'\'' // rune literal containing single quote character
'aa' // illegal: too many characters
'\xa' // illegal: too few hexadecimal digits
'\0' // illegal: too few octal digits
'\uDFFF' // illegal: surrogate half
'\U00110000' // illegal: invalid Unicode code point
双引号和反引号用于字符串文字。
`abc` // same as "abc"
`\n
\n` // same as "\\n\n\\n"
"\n"
"\"" // same as `"`
"Hello, world!\n"
"日本語"
"\u65e5本\U00008a9e"
"\xff\u00FF"
"\uD800" // illegal: surrogate half
"\U00110000" // illegal: invalid Unicode code point
推荐阅读
- html - 我是否需要使用 ttf 上传来支持跨浏览器字体?
- node.js - 处理嵌套的 firebase 函数
- css - 顺风 CSS 中相同高度的卡片
- css - 双 & 号选择器 '&&' 有什么作用(在 Material-UI React 中使用 makeStyles 覆盖根类)?
- python - 如何在某个索引处将具有相同元素的元组组合在一起?
- android - Gradle 版本 6.7.1 - 升级失败
- postgresql - Azure PostgreSQL 时间点还原不起作用
- python - 如何调整随机森林模型中的特征权重?
- tensorflow - Keras层关键字不理解
- c# - 在剃刀视图中连接字符串