Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
该fmt包有一个 Scan 函数,它读取标准输入,并将连续的空格分隔值写入您提供的变量。有没有办法将它与切片一起使用,以便我可以创建切片 n 的切片,并扫描读取 n 个值并将它们放入切片中?
fmt
只需将您的呼叫包装fmt.Scan在一个for循环中即可。
fmt.Scan
for