方法一:
1 $str = "abcd" 2 $s2 = $str.GetEnumerator() #$s2是无法使用下标的方式进行索引的,因为其不是array 3 $s2 | % {$_ + "y8y"}
1 $str = "abcd" 2 Foreach ($s in $str.GetEnumerator()) {$s + "y8y"}
方法二:
1 $str = "abcd" 2 $str.tochararray()
输出结果:
ay8yby8ycy8ydy8y