题解 | #统计字符#
统计字符
http://www.nowcoder.com/practice/539054b4c33b4776bc350155f7abd8f5
有点懒,直接用string模块的字符集去处理判断拉倒,无脑干
from string import ascii_letters, digits, punctuation, whitespace
while True:
try:
l_count, d_count, p_count, w_count = 0, 0, 0, 0
for x in input():
if x in ascii_letters:
l_count += 1
elif x in digits:
d_count += 1
elif x in punctuation:
p_count += 1
elif x in whitespace:
w_count += 1
print(l_count)
print(w_count)
print(d_count)
print(p_count)
except EOFError:
break