myList=[4,1,7,0] print(len(myList)) for i in range(len(myList)-1):#每循环一次找出最大值 for j in range(0,len(myList)-1-i): if myList[j]>myList[j+1]: tmp=myList[j] myList[j]=myList[j+1] myList[j+1]=tmp print(myList)