📅  最后修改于: 2022-03-11 15:01:00.229000             🧑  作者: Mango
Swift 5
let str = "abcdef"
print( String(str.characters.prefix(1)) ) // output: "a"
print( String(str.characters.prefix(3)) ) // output: "abc"