san1412
发表于 2020-5-28 12:02:29
list1 = list('easqWAwaeq')
list2 = []
for i in list1:
if i.upper() == i:
list2.append(i) #将大写的字母存在list2
list1 =
list1.sort()
list2.sort()
for i in list2:
for j in list1:
if j.upper() == i:
list1 = i
break
for i in list1:print(i,end = '')
谢啾啾
发表于 2020-11-7 10:27:28
string = 'easqWAwaeq'
string_A = []
string_a = []
# 将大小写字母分别放置不同的列表中
for each in string:
if each.isupper():
string_A.append(each)
else:
string_a.append(each)
# 使用ascii码进行排序
string_a.sort()
string_A.sort()
# 将大写字母插入小写字母队列
for i in string_a:
for j in string_A:
if ord(j)+32 == ord(i):
pos = string_a.index(i)
pop_pos = string_A.index(j)
string_a.insert(pos, string_A.pop(pop_pos))
break
for each in string_a:
print(each,end='')
aironeng
发表于 2020-11-16 09:02:03
学习
sanchuan555
发表于 2020-12-30 00:13:34
str_squ=input('请输入大小写字母:')
list1=[]
listupper=''
listlower=''
for i in str_squ:
list1.append(i)
list1.sort()#对字母进行排序
print(list1)
for a in range(len(list1)):#大小写字母分开
if list1.isupper():
listupper=listupper+list1
else:
listlower=listlower+list1
print(listlower,listupper)
def splitA(str_input):
listmedium=[]
a=''
for i in range(len(str_input)-1):
if str_input==str_input:
a=a+str_input
else:
a=a+str_input+' '
a=a+str_input
listupper_s=a.split(' ')
return (listupper_s)#不同字母拆分
lower=splitA((listlower))
upper=splitA(listupper)
print(lower,upper)
concentrate_lower=[]
for menber in lower:#把小写组首字母提出来转为大写
concentrate_lower.append(menber.upper())
print(concentrate_lower)
l_tra_u_dir={}#构建小写字母的查找字典
for n in range(len(concentrate_lower)-1):
l_tra_u_dir]=lower
print(l_tra_u_dir)
local_num=0
for n in l_tra_u_dir:
if n==upper:
upper=upper+l_tra_u_dir
else:
pass
local_num+=1
print(upper)
final_str=''
for i in upper:
final_str=final_str+i
print(final_str)
不知道ord()函数,捣鼓了两三天,反正弄出来了,还蛮有收获的。