Go 语言中的 fmt.Print("print some") 和 print("print some") 有什么区别?var a intfmt.Print("In Print ", &a, "\n ")print("In print ", &a, "\n")两者提供相同的结果。结果 :In Print 0xcSameAddressLocationIn print 0xcSameAddressLocation 但是,当我这样做时:ar := []int{1, 2, 3, 4, 5, 6, 7, 8}print("In print ", &ar, "\n")print("In print ", ar[0], "\n")print("In print ", ar, "\n")fmt.Print("In fmt.Print ", &ar, "\n")fmt.Print("In fmt.Print ", &ar[0], "\n")fmt.Print("In fmt.Print ", ar[0], "\n")fmt.Print("In fmt.Print ", ar, "\n")结果:In print 0xcAddressLocation1In print 1In print [8/8]0xcAddressLocation2In fmt.Print &[1 2 3 4 5 6 7 8]In fmt.Print 0xcAddressLocation2In fmt.Print 1In fmt.Print [1 2 3 4 5 6 7 8]有人可以请教一下这是如何工作的以及“print()”和“fmt.Print()”在 Go 语言中分别做什么吗?
- 1 回答
- 0 关注
- 105 浏览
添加回答
举报
0/150
提交
取消