"""
Version: 0.1
Author: freshbin
Date: 2019年8月21日
"""
print("=================================传递元组 start================================================")
def get_error_details():
return (2, 'details')
errnum, errstr = get_error_details()
print('errnum:{},errstr:{}'.format(errnum, errstr))
print("=================================传递元组 end================================================")
print("=================================lamdba表格 start================================================")
points = [{'x': 2, 'y': 3},
{'x': 4, 'y': 1}]
points.sort(key=lambda i: i['y'])
print(points)
print("=================================lamdba表格 end================================================")
print("=================================列表推导 start================================================")
listone = [2, 3, 4]
listtwo = [2 * i for i in listone if i > 2]
print(listtwo)
print("=================================列表推导 end================================================")
print("=================================元组或字典用于形参 start================================================")
def powersum(power, *args):
'''Return the sum of each argument raised to the specified powed.'''
total = 0
for i in args:
total += pow(i, power)
return total
powersum(2, 3, 4)
powersum(2, 10)
print("=================================元组或字典用于形参 end================================================")
print("=================================assert语句 start================================================")
mylist = ['item']
assert len(mylist) >= 1
print(mylist.pop())
# assert len(mylist) >= 1
print("=================================assert语句 end================================================")