- 列表排序:
L=[5,4,3,2,1]
L.sort()
print L
___________________________________________________________
L=[5,4,3,2,1]
for i in range(len(L)):
index=i
for j in range(i+1,len(L)):
if (L[index]>L[j]):
index=j
L[index],L[i]=L[i],L[index]
print L
- 字符串逆序
L="abcdefg"
print (L[::-1])
____________________________________________________________
#先将字符串转换为列表,再列表反转,最后再将列表组成字符串
L="abcdefg"
L=list(L)
L.reverse()
print(''.join())
————————————————————————————————————
L="abcdefg"
L1=list(L)
for i in range(len(L)):
L1[i]=L[-1-i]
print ''.join(L1)