Swift get the number of characters, string traversal

1. Get the number of characters in a string

Create a string with initial value

var str = "Hello"

if str.count == 0 {

    print("空值")

}

2. Traverse the string

for i in str {

    print(i)

}

Guess you like

Origin blog.csdn.net/zjpjay/article/details/97905325