1.获取字符串中字符个数 创建赋初值的字符串 var str = "你好啊" if str.count == 0 { print("空值") } 2.遍历字符串 for i in str { print(i) }