从控制台交互输入用户信息
接收信息主要方法为: 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)
}
打印结果
|
请发表评论