有一个字符串对象 S1=“A bird in the hand is worth two in the bush”,请用字符串对象的方法实现以下需求:a.共包含几个空格;b.将该字符串以空格分为若干个单词
3条回答 默认 最新
- ·星辰大海 2022-09-19 09:29关注
S1 = "A bird in the hand is worth two in the bush" print('S1的空格数:', S1.count(' ')) # 拆分S1 S1 = S1.split(' ') print(S1)
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用