原始字符串
Swift 5.1 斯威夫特
想要结果 截取前部)
Swift 5
let str: String = "Swift 5.1 斯威夫特"
let startIdx = str.startIndex
let index = str.index(startIdx, offsetBy: 7)
let subStr: String = String(str.prefix(upTo: index))
let str: String = "Swift 5.1 斯威夫特"
let startIdx = str.startIndex
let subStr: String = String(str.prefix(7))