python字符串降序排序怎么实现
lewis
2018-01-02
23次阅读
可以使用sorted函数对字符串进行降序排序,然后使用join方法将排好序的字符重新组合成一个字符串。示例如下:
s = "hello world"
sorted_s = ''.join(sorted(s, reverse=True))
print(sorted_s)
输出结果为:
wroolldlh e

发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。