输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。

import re

w_str = input("输入测试字符串:")
word_nums = 0
num_nums = 0
space_nums = 0
word = re.compile(r"\w")
num = re.compile(r"[0-9]")
space = re.compile(r" ")
for i in word.findall(w_str):
    word_nums += 1
for j in num.findall(w_str):
    num_nums += 1
for n in space.findall(w_str):
    space_nums += 1

print("小写字母数量为:", word_nums)
print("数字数量为:", num_nums)
print("空字符串数量为:", space_nums)