字符串

xiaoxiao2021-02-28  115

字符串

let str = "叼到飞起来" // for循环字符串 for s in str.characters { print(s) } // 打印字符串的长度 print(str.characters.count) // 转换成OC字符串(as: 类型转换) let ocStr = str as NSString print(ocStr.length) // 字符串拼接 let firstName = "Jerry" let lastName = "Yao" let age = 18 let fullName = firstName + lastName print(fullName) let desc = "Name is \(firstName) and age is \(age)" print(desc) // 字符串格式化 let h = 3 let m = 4 let s = 8 let time = String(format: "d:d:d", h, m, s) print(time)
转载请注明原文地址: https://www.6miu.com/read-59589.html

最新回复(0)