摘要: 1.迭代器与生成器2.装饰器1.迭代器与生成器迭代器迭代是Python最强大的功能之一,是访问集合元素的一种方式。迭代器是一个可以记住遍历的位置的对象。迭代器对象从集合等第一个元素开始访问,直到所有的元素被访问结束,迭代器只能往前不会后退。迭代器有两个基本的方法:iter()和next()字符串,列 阅读全文
posted @ 2017-05-29 10:34 Bruce.yin 阅读(149) 评论(0) 推荐(0) 编辑
摘要: #函数参数与局部变量#变量只有在被调用时才分配内存单元,在调用结束时,即刻释放所分配的内存单元,因此,形参只在函数内部有效,函数调用结束返回主调用函数后不能再使用该形参变量#可以是常量、变量、表达式、函数等,无论实参是何等类型的量,在进行函数调用时,他们都必须有确定的值,以便把这些值传送给形参,因此 阅读全文
posted @ 2017-05-20 11:02 Bruce.yin 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 import getpass 4 import sys 5 f = open('user.db','r') 6 welcome="欢迎来欢乐多购物平台" 7 out = '谢谢惠顾小店' 8 user_money = 5000000 9 shoppin... 阅读全文
posted @ 2017-05-13 10:17 Bruce.yin 阅读(121) 评论(0) 推荐(0) 编辑
摘要: user_list = ['宁光星','范春成','殷秋良','田建宇','王锐','李泉','周玉成','吴兴普','张二贤','孙晨光','所亚烦'] #print(type(user_list)) #统计传入的值在列表中出现的次数 #v = user_list.count('殷秋良') #找到传入值的第一个索引位置,并返回索引值 #v = user_list.index('殷秋良') 阅读全文
posted @ 2017-05-10 01:26 Bruce.yin 阅读(106) 评论(0) 推荐(0) 编辑
摘要: # ########################################## int 整数 ########################################## # 1. 当前整数的二进制表示,最少位数 # age = 4 # 100 # print(age.bit_length()) # 2. 获取当前数据的字节表示 # age = 15 # v = age.t... 阅读全文
posted @ 2017-05-09 23:30 Bruce.yin 阅读(309) 评论(0) 推荐(0) 编辑
摘要: 1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 zifu = '我的肚子真起来了' 4 newzifu = ' hhhh Mystomachisup hhhhhh ' 5 #print(newzifu) 6 #index查看字符中某个元素的索引位置 7 #v = newzifu.index('M') 8 #... 阅读全文
posted @ 2017-05-09 01:14 Bruce.yin 阅读(227) 评论(0) 推荐(0) 编辑
摘要: 1 import getpass 2 import sys 3 f = open('user.db','r') 4 welcome="欢迎来欢乐多购物平台" 5 data = f.read() 6 f.close() 7 user_db_list = [] 8 user_info_list = da 阅读全文
posted @ 2017-05-06 11:27 Bruce.yin 阅读(170) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/env python# -*- coding: utf-8 -*-i = 1while i < 11: if i == 7: i = i + 1 continue print(i) i = i + 1 #!/usr/bin/env python # -*- coding: utf-8 -*- i = 1 while i < 1... 阅读全文
posted @ 2017-05-06 02:39 Bruce.yin 阅读(91) 评论(0) 推荐(0) 编辑
摘要: 1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 print('欢迎土豪光临随心所欲旗舰店') 4 user_money = int(input('老板,请输入你拥有的总资产:')) 5 shopping_list = [] 6 shopping_car = {} 7 chose_list = [] 8 out = '谢谢惠顾... 阅读全文
posted @ 2017-05-06 02:38 Bruce.yin 阅读(233) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/env python # -*- coding: utf-8 -*- i = 1 num = 0 while i < 101: num = num + i print(num) #print(i) i = i + 1 阅读全文
posted @ 2017-05-06 02:37 Bruce.yin 阅读(93) 评论(0) 推荐(0) 编辑