代码
let str = "1234567890ASDFGHJKLoiuytrewq"
let endStr1 = str.prefix(10) // 抓头
debugPrint(endStr1)
debugPrint(str.suffix(10)) // 去尾
let index2 = str.index(str.startIndex, offsetBy: 5) //
let sub4 = str[index2..<str.endIndex] // 截头
debugPrint("q",sub4)
结果
"1234567890"
"Loiuytrewq"
"q","67890ASDFGHJKLoiuytrewq"
网友评论