本文共 1628 字,大约阅读时间需要 5 分钟。
print(abs(-1))print(abs(1))
print(all([1,2,'1']))print(all(['','']))
print(bin(3))
print(bool(''))print(bool(None))print(bool(0))
name='你好'print(bytes(name,encoding='utf-8').decode('utf-8'))
print(chr(78))
print(dir(all))
print(divmod(10,3))
dic={"name":"alex"}dic_str=str(dic)
print(hash('12345sdf'))name='sb'print(hash(name))print('=-=>after',hash(name))
print(help(all))
print(isinstance('abc',dict))
l=[1,3,100,-1]print(max(l))print(min(l))
print(list(zip(('a,''n','c'),(1,2,3))))p={'name': 'alex', 'age': 18, 'gender': 'none' }print(list(zip(p.keys(),p.values())))print(list(zip(['a','b'],'12345')))
age_dic={'alex_age':18,'wupeiqi_age':20,'zsc_age':100,'lhf_age':30}print(max(age_dic.values()))print(list(zip(age_dic.values(),age_dic.keys())))print(max(list(zip(age_dic.values(),age_dic.keys()))))---100[(100, 'zsc_age'), (30, 'lhf_age'), (20, 'wupeiqi_age'), (18, 'alex_age')](100, 'zsc_age')
取出字典中age最大的字典
people=[ {'name': 'alex', 'age':18}, {'name': 'wupeiqi', 'age':20}, {'name': 'zsc', 'age':100}, {'name': 'lhf', 'age':30}]# max可以指定处理方法print(max(people,key=lambda dic:dic['age']))---{'name': 'zsc', 'age': 100}# 相当于ret=[]for item in people: ret.append(item['age'])print(max(ret))max(ret)
转载地址:http://cvlja.baihongyu.com/