We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
os包和flag包获取命令行参数对比 通过os包获取命令行参数 如果用户没有传递参数会报错 需要严格按照代码中的顺序传递参数, 否则会造成数据混乱 不能指定参数的名称 获取到的数据都是字符串类型
这里的 int main() 要换成 func main() 不然编译通不过
package main import ( "os" "fmt" ) // 下面这个 int main( )要换成 func main ( ) ************************************ int main(){ name := os.Args[1] age := os.Args[2] fmt.Println("name = ", name) fmt.Println("age = ", age) }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
os包和flag包获取命令行参数对比
通过os包获取命令行参数
如果用户没有传递参数会报错
需要严格按照代码中的顺序传递参数, 否则会造成数据混乱
不能指定参数的名称
获取到的数据都是字符串类型
这里的 int main() 要换成 func main() 不然编译通不过
The text was updated successfully, but these errors were encountered: