本文共 464 字,大约阅读时间需要 1 分钟。
str = input()str1 = str.strip()index = 0count = 0while index < len(str1): while str1[index] != " ": index += 1 if index == len(str1): break count += 1 if index == len(str1): break while str1[index] == " ": index += 1print(count)
执行结果
C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\python.exe C:/Users/Administrator/PycharmProjects/untitled/day005/提取字符转里面的单词数.py4Process finished with exit code 0
转载地址:http://sdzxx.baihongyu.com/