代码:

#!/usr/bin/python
# -*- coding: UTF-8 -*-

inputString = raw_input('请输入字符串:')

eng = 0
number = 0
space = 0
other = 0

for i in inputString:
    if i.isalpha():
        eng += 1
    elif i.isspace():
        space += 1
    elif i.isdigit():
        number += 1
    else:
        other += 1

print 'eng=%d,space=%d,number=%d,other=%d' % (eng, space, number, other)

输出:

请输入字符串:www. 1 6 3 .com
eng=6,space=4,number=3,other=2

 

相关文章:

  • 2022-12-23
  • 2021-07-21
  • 2022-01-02
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-22
  • 2021-07-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案