发布时间:2019-09-25 08:23:39编辑:auto阅读(2111)
5.4 参数匿名函数字典排序
5.5 生成式和生成器
5.6 装饰器的作用
# *元组;**字典
def add(*args):
total = 0
for i in args:
total += i
print("total = {0}".format(total))
def sortDictValue(dict1):
print(sorted(dict1.items(), key =lambda d:d[1], reverse=False))
if __name__ == '__main__':
add(1, 2, 3, 4, 5)
s1 = lambda x, y: x + y
# def s1(x, y):
# return x + y
print(s1(10, 20))
aaa = dict(a = 100, b = 10, c = 50, d = 321)
l = list()
sortDictValue(aaa)
a = [x * x for x in range(1, 30) if x % 2 == 0]
print(type(a))
b = (x * x for x in range(1, 30) if x % 2 == 0)
print(type(b))
for i in b:
pass
# print(i)
def test(l):
for i in l:
yield i
print("i = {0}".format(i))
m = test([1, 2, 3])
print(type(m))
for i in m:
print(i)
def hello():
print("Hello world")
def test():
print("######start######")
hello()
print("######end######")
test()
上一篇: python3完全零基础入门视频
下一篇: python3第七天(输入和输出)
48451
47338
38221
35462
29920
26626
25598
20545
20240
18665
58°
70°
174°
118°
144°
261°
336°
332°
309°
399°