def bubbleSort(string):
lst = [ord(i) for i in string]
for i in range(len(lst) - 1):
for j in range(len(lst) - 1 - i):
if lst[j+1] > lst[j]:
temp = lst[j+1]
lst[j+1] = lst[j]
lst[j] = temp
return lst
if __name__ == '__main__':
string = 'helloworld'
sortData = bubbleSort(string)
newlst = []
for k in sortData:
newlst.append(chr(k))
print(''.join(newlst))
使用python将helloworld字符串倒序排序
最新推荐文章于 2023-02-13 10:38:09 发布
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
Python3.8
Conda
Python
Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本
601

被折叠的 条评论
为什么被折叠?



