swift4字符串截取截取某字符串的前10个字符串
let sub1 = str.prefix(10)
截取某字符串的后10个字符串
let str1 = str.suffix(10)
也可以换种写法
let index2 = str.dIndex, offsetBy: -10)
let sub4 = str[index2..&dIndex]
截取某字符串的第3个字符到第6个字符范围的字符串
let index3 = str.index(str.startIndex, offsetBy: 3)
字符串截取前四位let index4 = str.index(str.startIndex, offsetBy: 6)
let sub4 = str[index3..<index4]

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。