#选择排序 def insert_sort(li): for i in range (1,len(li)): # i表示摸到牌的下标 tem = li[i] j = i - 1 # j 是初始手中的牌 while j >= 0 and li[j] > tem :#找到比它小的牌 li[j+1] = li[j] j -= 1 li[j+1] = tem print(li) #每一趟的动作 li = [2,1,3,4,6,9,5,7,8] print(li) insert_sort(li) #print(li)