1. sorted的应用,将Iterable对象按照指定的顺序排序。具体参数可以通过help命令查看。
from collections import Iterable
l1 = ['zara', 'bubble','sort','jeans','jane']
l2 = ['zara', 'bubble','sort',('jeans','jane')]
s = 'zera and jane sort jeans bubble'
t1 = ('sorted', 'bubble', 'jeans', 'zara', 'jane')
t2 = ('sorted', 'bubble', 'jeans', ['zara', 'jane'])
dic = {'name':'jane', 'age': '22', 'name':'zera', 'age':'20'}
print(isinstance(l1, Iterable))
print(isinstance(l2, Iterable))
print(isinstance(dic, Iterable))
print('sorted l1: ',sorted(l1))
print('sorted s: ',sorted(s))
print('sorted t1: ',sorted(t1))
print('sorted dic: ',sorted(dic))
print('l2: ',l2)
print('sorted l1: ',sorted(l2))
result: