def count (qqq):
chars = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM'
nums = '0123456789'
blank = ' '
num_chars = 0
num_nums = 0
num_blank = 0
num_other = 0
for each in qqq:
if each in chars:
num_chars+=1
for each in qqq:
if each in nums:
num_nums+=1
for each in qqq:
if each in blank:
num_blank+=1
length=len(qqq)
num_other = length - num_chars - num_nums - num_blank
print('第一个字符串共有: 英文字母 %d 个,数字 %d 个,空格 %d 个,其他字符 %d 个', % (num_chars, num_nums, num_blank, num_other))
qqq=input('请输入字符串')
count(qqq)
那是因为你的百分号左边还有一个逗号,不要那个逗号就可以了 isdkz 发表于 2022-2-10 00:28
那是因为你的百分号左边还有一个逗号,不要那个逗号就可以了
好的谢谢
页:
[1]