Python输入一串字符串,输出字符串单词的个数

str = input("请您输入一串字符串:") str1 = str.strip() # 去掉字符串先后空格 index = 0 count = 0 while index < len(str1): while str1[index] != " ": # 当不是空格是,下标加1 index += 1 if index == len(str1): # 当下
相关文章
相关标签/搜索