所有的程序员都是编剧,所有的计算机都是烂演员。   
返回顶部
摘要: 阅读全文
posted @ 2018-05-18 14:04 steven丶syw 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2018-05-18 14:02 steven丶syw 阅读(193) 评论(0) 推荐(0) 编辑
摘要: a=1 def foo(): a=2 def foo2(): print(a) return foo2 y=foo() y() 包三层 def egon_name(): name='Steven' def monthly_pay(): money = 100000 def hehe(): print 阅读全文
posted @ 2018-05-13 12:16 steven丶syw 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 1、global:在局部修改全局变量 x=100 def foo(): global x x=200 foo() print(x) #todo 如果不写global,则打印为100 2、nonlocal:只在函数内部找变量,如果没有则报错 x=100 def a(): x=200 def b(): 阅读全文
posted @ 2018-04-26 18:22 steven丶syw 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 1、可引用 def foo(): return ('hello world!') a=foo print(a()) 2、可当返回值 def outer(): def inner(): print(111) return inner y=outer() y() #todo 如果将111改为inner 阅读全文
posted @ 2018-04-25 23:40 steven丶syw 阅读(180) 评论(0) 推荐(0) 编辑
摘要: a=1 def foo(): print(a) def foo2(): print(a) foo2() def foo3(): print(a) foo() foo3() def x1(): #todo 从内往外看 a=10 def x2(): a=20 def x3(): a=30 print(a 阅读全文
posted @ 2018-04-23 19:27 steven丶syw 阅读(174) 评论(0) 推荐(0) 编辑
摘要: a=10 def foo(): print(a) foo() # def foo2(a,b): # c=1 # print(a,b,c) # foo2(10,9) a=10 def foo1(): a=20 print(a) foo1() # 因为局部有一个值 所以打印为20 b=10 def fo 阅读全文
posted @ 2018-04-22 19:57 steven丶syw 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 在一个函数里再加一层或多层函数 def f1(): #todo 注意代码的缩进 def f2(): def f3(): print('c') f3() print('b') f2() print('a') f1() 阅读全文
posted @ 2018-04-22 19:15 steven丶syw 阅读(168) 评论(0) 推荐(0) 编辑
摘要: def foo(*args,**kwargs): print(args) print(kwargs) foo(1,21,111,22,11,x=1,y=2,z=3) # todo 可以接收任意形式,任意长度的参数 # todo 一定是**在后面 因为关键字必须在后 阅读全文
posted @ 2018-04-22 19:12 steven丶syw 阅读(167) 评论(0) 推荐(0) 编辑
摘要: def func(x,y,*args): print(x,y) print(args) func(1,2,3,4,5) # *处理按位置定义的多出的实参 # 然后赋值给*后的变量来保存成一个元组的形式 # args=(3,4,5) 1、等效 def func(x,y,*args): print(x, 阅读全文
posted @ 2018-04-22 19:07 steven丶syw 阅读(225) 评论(0) 推荐(0) 编辑