可以使用for循環遍歷字符串的每個字符。示例如下:
string = "Hello World" for char in string: print(char)
輸出結果為:
H e l l o W o r l d
你可以根據實際需求對每個字符進行處理,比如統計字符出現的次數、替換特定字符等。