📜  随机字符串 swift 代码示例

📅  最后修改于: 2022-03-11 15:01:01.635000             🧑  作者: Mango

代码示例1
func randomString(of length: Int) -> String {
    let letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    var s = ""
    for _ in 0 ..< length {
        s.append(letters.randomElement()!)
    }
    return s
}