Swift字符串格式化学习

2017-07-13  本文已影响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

上一篇 下一篇

猜你喜欢

热点阅读