可能是一個菜鳥問題,但我如何為字符串中的每個空格創建 for 語句?text = "Hello World, this is a string!"for spaces in text # do blah blah
1 回答

桃花長相依
TA貢獻1860條經驗 獲得超8個贊
獲取for循環中的每個字符并使用if條件檢查它是否為空格
text = "Hello World, this is a string!"
for character in text:
if character == " ":
# do blah blah
添加回答
舉報
0/150
提交
取消