摘要: 假设day21-lesson\bin\bin.pyday21-lesson\modul\main如何把main导入到bin文件中import syssys.path.append(r'C:\Users\Administrator\PycharmProjects\python_s3\day22\day 阅读全文
posted @ 2018-08-27 20:49 漫语慢蜗牛 阅读(229) 评论(0) 推荐(0) 编辑
摘要: while True: print('level1') choice=input('level>>:').strip() if choice=='quit':break while True: print('level2') choice=input('level2>>').strip() if c 阅读全文
posted @ 2018-08-27 20:48 漫语慢蜗牛 阅读(173) 评论(0) 推荐(0) 编辑
摘要: def run(): print('fron run') print('fron run') print('fron run') print('fron run') print('fron run')run() def test(): print('from run') yield 1 print( 阅读全文
posted @ 2018-08-24 10:12 漫语慢蜗牛 阅读(109) 评论(0) 推荐(0) 编辑
摘要: [i for i in range(10)] g_l=(i for i in range(10)) def test(): yield 1 yield 2 yield 3 yield 4res=test()print(res.__next__()) def test(): print('开始生孩子啦 阅读全文
posted @ 2018-08-23 21:44 漫语慢蜗牛 阅读(177) 评论(0) 推荐(0) 编辑
摘要: l=[1,2,3,4,5]print(list(map(lambda i:str(i),l))) from functools import reducereduce(lambda x,y:x+y,l,init=3) name=['alex_sb','linhaifeng']print(list(f 阅读全文
posted @ 2018-08-20 19:19 漫语慢蜗牛 阅读(256) 评论(0) 推荐(0) 编辑
摘要: print(zip(('a','b','c'),(1,2,3)))print(list(zip(('a','b','c'),(1,2,3))))#结果<zip object at 0x00EBB0F8>[('a', 1), ('b', 2), ('c', 3)] p={'name':'alex',' 阅读全文
posted @ 2018-08-19 19:34 漫语慢蜗牛 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 作用域:name='alex' def foo(): name='linhaifeng' def bar(): print(name)foo() def test(): passprint(test) def test1(): print('in the test1')def test(): pri 阅读全文
posted @ 2018-08-19 10:30 漫语慢蜗牛 阅读(90) 评论(0) 推荐(0) 编辑
摘要: y=2*x+1 def test(x,y,z) '注释' 代码 return restest() 局部变量与全局变量全局变量顶头写的 局部变量子程序中定义的变量 nam='sb'def change(): nam="dog" print(nam)change()print(nam) #结果dogsb 阅读全文
posted @ 2018-08-18 14:38 漫语慢蜗牛 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 变量name='alex' age=0 level= life=Truelife=False 字符串数字列表元组字典 可变不可变1、可变列表字典 2、不可变字符串数字元组 访问顺寻1、顺序访问字符串列表元组2、映射字典 3、直接访问数字 存放元素个数容器类型列表 元组字典 原子类型数字字符串 集合定 阅读全文
posted @ 2018-08-17 12:42 漫语慢蜗牛 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 13、有两个列表 l1=[11,22,33] l2=[22,33,44] a.获取内容相同的元素列表 l4=[] for item1 in l1: for item2 in l2: if item1==item2: l4.append(item1) #用in更简单 b.获取l1中有,l2中没有的元素 阅读全文
posted @ 2018-08-16 12:36 漫语慢蜗牛 阅读(295) 评论(0) 推荐(0) 编辑