标签:https str def stop eva res slice rev hello
python内置函数1:https://www.cnblogs.com/raitorei/p/11813694.html
# max,min高级玩法 # l=[1,3,100,-1,2] # print(max(l)) # print(min(l)) # # # print(list(zip((‘a‘,‘n‘,‘c‘),(1,2,3)))) # print(list(zip((‘a‘,‘n‘,‘c‘),(1,2,3,4)))) # print(list(zip((‘a‘,‘n‘,‘c‘,‘d‘),(1,2,3)))) # # p={‘name‘:‘alex‘,‘age‘:18,‘gender‘:‘none‘} # print(list(zip(p.keys(),p.values()))) # # print(list(p.keys())) # # print(list(p.values())) # # print(list(zip([‘a‘,‘b‘],‘12345‘))) # l=[1,3,100,-1,2] # print(max(l)) # print(min(l)) # age_dic={‘alex_age‘:18,‘wupei_age‘:20,‘zsc_age‘:100,‘lhf_age‘:30} # print(max(age_dic.values())) # # #默认比较的是字典的key # # print(max(age_dic)) # # for item in zip(age_dic.values(),age_dic.keys()): #[(18,‘alex_age‘) (20,‘wupeiqi_age‘) () () ()] # print(item) # # print(‘=======>‘,list(max(zip(age_dic.values(),age_dic.keys())))) # l=[ # (5,‘e‘), # (1,‘b‘), # (3,‘a‘), # (4,‘d‘), # ] # # l1=[‘a10‘,‘b12‘,‘c10‘,100] #不同类型之间不能进行比较 # l1=[‘a10‘,‘a2‘,‘a10‘] #不同类型之间不能进行比较 # print(list(max(l))) # print(‘--->‘,list(max(l1))) # l=[1,3,100,-1,2] # print(max(l)) # dic={‘age1‘:18,‘age2‘:10} # print(max(dic)) #比较的是key # print(max(dic.values())) #比较的是key,但是不知道是那个key对应的 # # print(max(zip(dic.values(),dic.keys()))) #结合zip使用 # # # people=[ # {‘name‘:‘alex‘,‘age‘:1000}, # {‘name‘:‘wupei‘,‘age‘:10000}, # {‘name‘:‘yuanhao‘,‘age‘:9000}, # {‘name‘:‘linhaifeng‘,‘age‘:18}, # ] # # max(people,key=lambda dic:dic[‘age‘]) # print(‘值:‘,max(people,key=lambda dic:dic[‘age‘])) # ret=[] # for item in people: # ret.append(item[‘age‘]) # print(ret) # max(ret) # 对应ascll的值 # print(chr(97)) # print(ord(‘a‘)) # print(pow(3,3)) #3**3 # print(pow(3,3,2)) #3**3%2 # 逆序 # l=[1,2,3,4] # print(list(reversed(l))) # print(l) # round() 方法返回浮点数x的四舍五入值。 # print(round(3.5)) # set() 函数创建一个无序不重复元素集,可进行关系测试,删除重复数据,还可以计算交集、差集、并集等。 # print(set(‘hello‘)) # 切片 # l=‘hello‘ # s1=slice(3,5) # s2=slice(1,4,2) # # print(l[3:5]) # print(l[s1]) # print(l[s2]) # print(s2.start) # print(s2.stop) # print(s2.step) # 排序 # l=[3,2,1,5,7] # l1=[3,2,‘a‘,1,5,7] # print(sorted(l)) # # print(sorted(l1)) #排序本质就是在比较大小,不同类型之间不可以比较大小 # people=[ # {‘name‘:‘alex‘,‘age‘:1000}, # {‘name‘:‘wupei‘,‘age‘:10000}, # {‘name‘:‘yuanhao‘,‘age‘:9000}, # {‘name‘:‘linhaifeng‘,‘age‘:18}, # ] # print(sorted(people,key = lambda dic:dic[‘age‘])) # name_dic={ # ‘abyuanhao‘: 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()))) # print(str(‘1‘)) # print(type(str({‘a‘:1}))) # dic_str=str({‘a‘:1}) # print(type(eval(dic_str))) # l=[1,2,3,4] # print(sum(l)) # print(sum(range(5))) # # 查看类型 # print(type(1)) # # msg=‘123‘ # # if type(msg) is str: # msg=int(msg) # res=msg+1 # print(res) # vars() 函数返回对象object的属性和属性值的字典对象。 # def test(): # msg=‘撒旦法阿萨德防撒旦浪费艾丝凡阿斯蒂芬‘ # print(locals()) # print(vars()) # test() # print(vars(int)) # 调用其他文件 #import------>sys----->__import__() # import test # test.say_hi() # import ‘test‘#报错 # module_name=‘test‘ # m=__import__(module_name) # m.say_hi()
标签:https str def stop eva res slice rev hello
原文地址:https://www.cnblogs.com/raitorei/p/11814181.html