python之路1 函数 内置函数之三
# l = [ # (5,'e'), # (1,'b'), # (2,'a'), # (3,'c') # ] # print(list((max(l)))) # #ll = ['a10','b12','c10',1]#不同数据类型不能进行比较 # ll = ['a10','b12','c10'] # print(list((max(ll)))) # age_dic={'age1':13,'age2':12,'age3':14,'age':100 # # } # print(max(age_dic.values())) # print(max(age_dic))#默认按keys取值 # for i in zip(age_dic.values(),age_dic.keys()): # print(i) # #print(max(zip(age_dic.values(),age_dic.keys())))#取一个值 # print(list(max(zip(age_dic.values(),age_dic.keys()))))#结合zip使用 # people = [ # {'name':'alex','age':1000}, # {'name':'wuliu','age':12} # ] # # print(max(people,key=lambda dic:dic['age'])) # # res = [] # for i in people: # res.append(i['age']) # print(res) # print(max(res)) #他会显示字符在阿斯克码的位置 #print(ord('a')) #几的几次方,如10的3次方 # print(pow(10,3)) # # print(pow(3,3,2))#取余如9除2 # l=[1,2,3,4] # #reversed()也是一个可迭代对象,取值加for或list # #把元素反转 # print(list(reversed(l))) # #四舍五入 # print(round(3.5)) # # # print(set('hello')) # l = 'hello' # print(l[3:5]) # sl = slice(3,5) # print(l[sl]) # people = [ # {'name':'alex','age':1000}, # {'name':'wuliu','age':12} # ] # print(sorted(people,key=lambda dic:dic['age'])) # #排序本质就是在比较大小,不同类型不能比较 # l = [3,3,11,44,1,444,2] # print(sorted(l)) # name_dic={ # 'adyuan':11900, # 'alex':1200, # 'wupei':300 # } # print(sorted(name_dic)) # print(sorted(name_dic,key=lambda key:name_dic[key])) # print(sorted(zip(name_dic.values(),name_dic.keys()))) #str转换数据类型 #type查看数据类型 # print(str('1')) # #print(str({'a':3})) # print(type(str({'a':3}))) #sum()求和 #l=[1,2,34,4,4] # print(sum(l)) # print(sum(range(5))) # msg= '2113' # if type(msg)is str: # msg =int(msg) # res=msg+1 # print(res) # def test(): # msg="fbsj" # print(locals()) # print(vars()) # test() # print(vars(int)) #模块就是py文件 #import 不导入字符串 import test #py文件名加点直接调用里面的函数 test.test() module_name='test' m=__import__(module_name) m.test()