swift3 String截取

  • string去掉最后一个字符
        let sessionId = "this is a test"
        let index = sessionId.index(sessionId.endIndex, offsetBy: -1)
        // let suffix = sessionId.substring(from: index)
        let suffix = sessionId.substring(to: index)
        print(suffix)

你可能感兴趣的:(swift3 String截取)