golang用空格接受输入 [英] golang accepting input with spaces
本文介绍了golang用空格接受输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I'm just starting with GO and I understand that SCANF uses spaces as a separator in GO.
我刚刚开始使用GO,并且我明白SCANF在GO中使用空格作为分隔符。 (%s,& input)
fmt.Scanf("%s",&input)
我无法真正找到接受包含空格为有效字符。
I cant really find a way to accepts inputs that contain spaces as valid characters.
推荐答案
当用户按下Enter键时,表示输入结束 p>
When the user presses enter it signifies the end of input
看起来像 fmt.Scanln
That looks like fmt.Scanln
Scanln
类似于Scan
,但停止在换行符处扫描,并且在最后一项后必须有换行符或EOF。
Scanln
is similar toScan
, but stops scanning at a newline and after the final item there must be a newline or EOF.
这篇关于golang用空格接受输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文