
对字符串相关内容不熟悉,想知道里面的要求要用什么语句来满足,诚恳求学,希望能够解答
def count(s):
alpha,num,space,other=0,0,0,0
for i in s:
if i.isalpha():
alpha+=1
elif i.isdigit():
num+=1
elif i.isspace():
space+=1
else:
other+=1
print('英文字符数{},数字字符数{},空格字符数{},其他字符数{}'.format(alpha,num,space,other))
if alpha==len(s):
return 1
return 0
t=0
l=[]
for i in range(10):
s=input("请输入一个字符串:")
l.append(s)
t+=count(s)
if t==10:
for i in l:
print(i.upper ())
else:
print('不存在单纯字母字符串')
a = []
b = {}
d = []
e = 0
for i in range(10):
c = input()
for i in c:
b[i] = b.get(i,0)+1
a.append(b)
d.append(c)
b = {}
for i in a:
for key,value in i.items():
print("{}:{}".format(key,value),end = " ")
print("",end = "\n")
for i in d:
if i.isalpha():
e = 1
print(i.upper())
if e == 0:
print("no")
# -*- coding:utf-8 -*-
from collections import Counter
str = input('请输入一个十位数的字符串: ')
## abcaedolds
if len(str) != 10:
print('{} 字符串个位数不是10位'.format(str))
else:
for k,v in dict(Counter(str)).items():
print( '字符 {} 出现的次数是 {} 次'.format(k,v) )
if str.isalpha():
result = str.upper()
print('{} 转化成大写字母是 {}'.format(str , result))
else:
print( '不存在单纯字母字符串' )