|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- def search(x , y):
- word = 'asdfghjklqwertyuiopzxcvbnmASDFGHJKLQWERTYUIOPMNBVCXZ'
- number = '0123456789'
- blank = ' '
- other_str = r'''`!@#$%^&*()_+-=/*{}[]\|'";:/?,.<>'''
- a = b = 0
- length1 = len(x)
- length2 = len(y)
- count1 = count2 = count3 = count4 = 0
- while a <= length1 - 1:
- if x[a] in word:
- count1 += 1
- if x[a] in number:
- count2 += 1
- if x[a] in blank:
- count3 += 1
- if x[a] in other_str:
- count4 += 1
- a += 1
- print('第1个字符串共有:英文字母',count1,'个,数字',count2,'个,空格',count3,'个,其他字符',count4,'个。')
- count11 = count22 = count33 = count44 = 0
- while b <= length2 - 1:
- if y[b] in word:
- count11 += 1
- if y[b] in number:
- count22 += 1
- if y[b] in blank:
- count33 += 1
- if y[b] in other_str:
- count44 += 1
- a += 1
- print('第2个字符串共有:英文字母',count11,'个,数字',count22,'个,空格',count33,'个,其他字符',count44,'个。')
- x='jehfewu8349287]][][][][][] '
- y='3fnshgnn'
- search(x,y)
复制代码
各位帮我看一下为什么只能打印x内的内容,y里面的内容没有打印呢?
本帖最后由 lirenbing01 于 2020-10-27 14:18 编辑
- print('第2个字符串共有:英文字母',count11,'个,数字',count22,'个,空格',count33,'个,其他字符',count44,'个。')
- 前一句 是b+=1
复制代码
你用a+=1 就死循环在第二大段了
|
|