zoukankan      html  css  js  c++  java
  • 16 复习一下format格式化输出

     1 mystring = input('输入一带有字母数字特殊符号的字符串:')
     2 alpha = 0
     3 space = 0
     4 number = 0
     5 other = 0
     6 for i in mystring:
     7     if i >= 'a' and i <= 'z' or i >= 'A' and i <= 'Z':
     8         alpha += 1
     9     elif i >= '0' and i <= '9':
    10         number += 1
    11     elif i.isspace():
    12         space += 1
    13     else:
    14         other += 1
    15 print('alpha:{},number:{},space:{},other:{}'.format(alpha,number,space,other))
  • 相关阅读:
    C
    B
    A
    poj1222
    请求转发和重定向
    中文乱码
    Servlet 第一天
    Oracle 锁
    Oracle 包的学习
    初学Linux
  • 原文地址:https://www.cnblogs.com/reaix/p/12670995.html
Copyright © 2011-2022 走看看