doukang7501 2019-08-21 10:07
浏览 17
已采纳

打印和Go中打印之间的区别[重复]

This question already has an answer here:

What will be the difference between the fmt.Print("print something") and just print("print something") in Go lang.

var a int
fmt.Print("In Print ", &a, "
 ")
print("In print ", &a, "
")

Both provide the same result.

Result :

In Print 0xcSameAddressLocation
In print 0xcSameAddressLocation 

However when I do this :

ar := []int{1, 2, 3, 4, 5, 6, 7, 8}
print("In print ", &ar, "
")
print("In print ", ar[0], "
")
print("In print ", ar, "
")
fmt.Print("In fmt.Print ", &ar, "
")
fmt.Print("In fmt.Print ", &ar[0], "
")
fmt.Print("In fmt.Print ", ar[0], "
")
fmt.Print("In fmt.Print ", ar, "
")

Result:

In print 0xcAddressLocation1
In print 1
In print [8/8]0xcAddressLocation2
In fmt.Print &[1 2 3 4 5 6 7 8]
In fmt.Print 0xcAddressLocation2
In fmt.Print 1
In fmt.Print [1 2 3 4 5 6 7 8]

Can someone please how this works and what "print()" and "fmt.Print()" do in Go Language respectively.

</div>
  • 写回答

1条回答 默认 最新

  • douqiaotong8682 2019-08-21 10:15
    关注

    print() is builtin funstion and it is not guaranteed to stay in the language. See builtin.go

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP