#冒泡排序 def bubble(list): for i in range(len(list) - 1,0,-1): for j in range(0,i): while list[j] > list[j + 1]: temp = list[j] list[j] = list[j + 1] list[j +1] = temp return list #键入一个列表 def inputIntlist(): x = input("请输入一个整数列表(以逗号为分隔):") xlist = x.split(",") xlist = [int(xlist[i]) for i in range(len(xlist))] return xlist if __name__ == '__main__': list = inputIntlist() sortlist = bubble(list) print(sortlist)