17.python built-in functions 2

python built-in function 1: https://www.cnblogs.com/raitorei/p/11813694.html

# Max, min advanced play 
# 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()))
#
# # The default is relatively dictionary 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 = [ 'AlO' , 'b12', 'c10' , 100] # can not be compared between different types 
# L1 = [ 'AlO', 'A2', 'AlO'] # can not be compared between different types 
# Print (List (max ( L))) 
# Print ( '--->', List (max (L1)))



# L = [1,3,100,-1,2] 
# Print (max (L)) 
# DIC = { 'AGE1': 18 is, 'Age2': 10} 
# Print (max (DIC)) # key comparison is 
# Print (max (dic.values ())) # comparison is key, but do not know the key corresponding
#
# Print (max (zip (dic.values (), dic.keys ()))) # zip used in combination
#
#
# 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)

# Corresponding to the value of ascll 
# Print (CHR (97)) 
# Print (the ord ( 'A'))

# print(pow(3,3))  #3**3
# print(pow(3,3,2))  #3**3%2

# Reverse 
# L = [1,2,3,4] 
# Print (List (the reversed (L))) 
# Print (L)

# Round () method returns the rounded value of the floating point number x. 
# Print (round (3.5))

# The SET () function to create an unordered set of elements is not repeated, the relationship can be tested, remove duplicate data, you can calculate the intersection, difference, and sets. 
# 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)

# Sort 
# L = [3,2,1,5,7] 
# L1 = [3,2-, 'A', 1,5,7] 
# Print (the sorted (L)) 
# # Print (the sorted (L1) ) Sort # essentially size comparison between different types can not compare the size of 
# people = [ 
#      { 'name': 'Alex', 'Age': 1000}, 
#      { 'name': 'wupei', 'Age ': 10000}, 
#      {' name ':' yuanhao ',' Age ': 9000}, 
#      {' name ':' linhaifeng ',' Age ': 18 is}, 
# ] 
# Print (the sorted (people, Key = DIC the lambda: 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)))
#
# View Type 
# Print (of the type (1))
#
# msg='123'
#
# if type(msg) is str:
#     msg=int(msg)
#     res=msg+1
#     print(res)

# VARS () function returns a dictionary object attributes and attribute values of the object of the object. 
# DEF the Test (): 
#      msg = 'anti-Satan Satan Faesade Van Lang Fei Aisi Aspen Tiffen' 
#      Print (about locals ()) 
#      Print (VARS ()) 
# the Test () 
# Print (VARS (int))

# Call other files 
# Import ------> SYS -----> Import __ __ () 
# Import the Test 
# test.say_hi ()

# import 'test'#报错
# module_name='test'
# m=__import__(module_name)
# m.say_hi()

 

Guess you like

Origin www.cnblogs.com/raitorei/p/11814181.html