在 Swift 3 中打印 [英] Print in Swift 3

查看:61
本文介绍了在 Swift 3 中打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道这两种在 Swift 中打印对象的方式有什么不同.结果似乎相同.

i would like to know what's the different between these two way to print the object in Swift. The result seems identical.

var myName : String = "yohoo" 
print ("My name is \(myName).")

print ("My name is ", myName, ".")

推荐答案

功能上几乎没有区别,逗号只是在字符串前后输入一个空格.

There is almost no functional difference, the comma simply inputs a space either before or after the string.

let name = "John"

// both print "Hello John"
print("Hello", name)
print("Hello \(name)")

这篇关于在 Swift 3 中打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆