#冒泡排序 def BubbleSort(mylist): n = len(mylist) i = 0 j = 0 bExchange = False for i in range(1, n): bExchange = False j = n - 1 while j >= i: if mylist[j] < mylist[j - 1]: tmp = mylist[j] mylist[j] = mylist[j - 1] mylist[j - 1] = tmp bExchange = True j = j - 1 if not bExchange: break mylist0 = [11, 10, 4, 2, 1, 55, 99, 102] BubbleSort(mylist0) print(mylist0)