import UIKit var str = "Hello, playground" var index = str.index(of: ",") //得到空格在字符串中的位置 //Swift 3.0 let greeting = str[str.startIndex ..< index!] //得到hello index = str.index(index!, offsetBy: 1) //空格位置往后移动一位 let name = str[index! ..< str.endIndex] //playground //Swift 4.0 //得到hello let greetings = str.prefix(upTo: index!) let greetingss = str[..<index!] //空格位置往后移动一位 index = str.index(index!, offsetBy: 1) //playground let names = str.suffix(from: index!) let namess = str[index!... ]import UIKit var str = "Hello, playground" va