// 使用range区间来操作
let name = "yuanzhiying"
let indexStart = name.startIndex
let index2 = name.index(indexStart, offsetBy: 6)
print(String(name[indexStart..<index2]))
// yuanzh
// 使用SubString方法来操作
let name2 = "yuanzhiying"
print(name2.dropFirst(0).prefix(6))
// yuanzh
网友评论