计算字符串中al_num,spance_num,digit_num,other_num的个数
Posted 失落的黎明
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了计算字符串中al_num,spance_num,digit_num,other_num的个数相关的知识,希望对你有一定的参考价值。
1 def jisuan(x) : 2 al_num = 0 3 spance_num = 0 4 digit_num = 0 5 other_num = 0 6 for i in x : 7 if i.isdigit() : 8 digit_num += 1 9 elif i.isspace() : 10 spance_num += 1 11 elif i.isalpha() : 12 al_num += 1 13 else : 14 other_num += 1 15 return (al_num,spance_num,digit_num,other_num) 16 17 18 r= jisuan("qwerrwqrqrwqr erwqrdsfdad#sfa") 19 20 print(r)
以上是关于计算字符串中al_num,spance_num,digit_num,other_num的个数的主要内容,如果未能解决你的问题,请参考以下文章