美文网首页
Swift字符串格式化学习

Swift字符串格式化学习

作者: 淡看风雨 | 来源:发表于2017-07-13 11:15 被阅读0次

let elem1 = 1

let elem2 = 2

let str = String(format:"%02d:%02d",elem1,elem2)

print(str)

let name = "zz"

let age = 11

let height = 1.22

let info = "my name is \(name),age is \(age),height is \(height)"

let urlString = "www.sss.com"

let header = (urlString as NSString).substring(to: 3)

let body = (urlString as NSString).substring(with: NSMakeRange(4, 3))

let footer = (urlString as NSString).substring(from: 8)

for c in urlString.characters {

print(c)

}

let str4 = "hello"

let str5 = "world"

let str6 = str4 + str5

相关文章

网友评论

      本文标题:Swift字符串格式化学习

      本文链接:https://www.haomeiwen.com/subject/vdrwhxtx.html