I have a variable like this:
words="这是一条狗。"
I want to make a for loop on each of the characters, one at a time, e.g. first character="这"
, then character="是"
, character="一"
, etc.
The only way I know is to output each character to separate line in a file, then use while read line
, but this seems very inefficient.
- How can I process each character in a string through a for loop?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…