首页 > 其他 > 详细

16 复习一下format格式化输出

时间:2020-04-10 09:44:03      阅读:70      评论:0      收藏:0      [点我收藏+]
 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))

 

16 复习一下format格式化输出

原文:https://www.cnblogs.com/reaix/p/12670995.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!