import seaborn as sns
import matplotlib.pyplot as plt
f=open("Nabokov.txt")
x=f.read()
c=[]
b=[' ','(', ')', '{', '}', '[', ']', ':', ';', '"', "'", '<', '>', ',', '.', '?', '!','-', '@', '#', '$', '%', '^', '&', '*', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0']
for i in range(len(b)):
if b[i] in x:
x=x.replace(b[i],"")
x=x.upper()
**x = ''.join(sorted(x,))**
print(x)
print(len(x))
a=['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
for i in range(26):
print(x.count(a[i]),"=",a[i],";",(x.count(a[i])/len(x))*100)
c.append(x.count(a[i]))
sns.barplot(x=a, y=c)
plt.show()
我突出显示的行对该行进行排序。但它并没有按照我的需要进行排序。
示例 [addbddbbggac]
输出 [ddddbbbggaac]
这就是我需要的。
它如何排序
?
请帮忙
