Go 从控制台获取用户信息
作者:互联网
从控制台交互输入用户信息
接收信息主要方法为: fmt.Scanln
package main
import (
"fmt"
)
func main() {
var name string
var age byte
var sal float32
var Ispass bool
fmt.Println("Please input name:")
fmt.Scanln(&name)
fmt.Println("Please input age:")
fmt.Scanln(&age)
fmt.Println("Please input sal:")
fmt.Scanln(&sal)
fmt.Println("Please input Ispass:")
fmt.Scanln(&Ispass)
fmt.Printf("name: %v\nage: %v\nsal: %v\nIspass: %v",name,age,sal,Ispass)
}
打印结果
标签:name,Scanln,fmt,sal,Please,var,获取,Go,控制台 来源: https://www.cnblogs.com/lixinliang/p/15073053.html