用Python实现统计字符串中单词个数 def main(): s = input("input a string:") ls = s.split(" ") print(len(ls)) if __name__ == '__main__': main()