from pip._vendor.distlib.compat
import raw_input
str = raw_input(
"请输入待统计字符串:")
letters =
0
space =
0
digit =
0
others =
0
for i
in str:
if i.isdigit():
digit +=
1
elif i.isspace():
space +=
1
elif i.isalpha():
letters +=
1
else:
others +=
1
print (
'char = %d,space = %d,digit = %d,others = %d' % (letters,space,digit,others))
转载于:https://www.cnblogs.com/bilaisheng/p/10211058.html
相关资源:JAVA上百实例源码以及开源项目