摘要: #列表生成式a = [x for x in range(10)]print(a)def f(n): return n**3b = [f(x) for x in range(10)]print(b)#生成器#创建方法1s = (x*2 for x in range(10))#print(next(s) 阅读全文
posted @ 2018-09-11 15:37 zhoupeng_L 阅读(120) 评论(0) 推荐(0)
摘要: import time#装饰器之闭包def outer(): x = 10 def inner():#inner是内部函数 print(x) return innerouter()()#闭包=内部函数+函数创建的外部环境#闭包函数的条件:1.为内部函数 2.对外部只作用于的变量进行引用#装饰器:对已 阅读全文
posted @ 2018-09-06 16:21 zhoupeng_L 阅读(182) 评论(0) 推荐(0)
摘要: #函数创建方法#def 函数名(形参):# 函数体#low adddef add(x,y): print(x+y)add(3,4)#high add 单*可接收无命名参数def add_high(*args): sum = 0 for i in args: sum += i print(sum)ad 阅读全文
posted @ 2018-08-29 14:07 zhoupeng_L 阅读(165) 评论(0) 推荐(0)
摘要: #创建集合方法a = set([1,2,3,4,5])b = set([4,5,6,7,8])#交集print(a & b)print(a.intersection(b))#并集print(a | b)print(a.union(b))#difference just in firstprint(a 阅读全文
posted @ 2018-08-27 16:23 zhoupeng_L 阅读(138) 评论(0) 推荐(0)
摘要: # -*- coding: utf-8 -*-# @Time : 2018/8/6 8:31# @Author : Rolland# @File : dict&str.py# @Software: PyCharmmenu = { '中国':{ '广东':{ '广州':{ '网易游戏':{}, '酷狗 阅读全文
posted @ 2018-08-08 12:56 zhoupeng_L 阅读(345) 评论(0) 推荐(0)
摘要: # -*- coding: utf-8 -*-# @Time : 2018/8/6 11:48# @Author : Rolland# @Email : zhoupeng_L@163.com# @File : dict&str.py# @Software: PyCharm#dictdic = {'n 阅读全文
posted @ 2018-08-06 14:36 zhoupeng_L 阅读(284) 评论(0) 推荐(0)
摘要: 简单购物车功能:输入现有金额,选择购物,判断金额是否充足,结束打印当前所购物品,剩余金额等 阅读全文
posted @ 2018-07-11 12:04 zhoupeng_L 阅读(140) 评论(0) 推荐(0)
摘要: 一、列表增删查改name = ['zhoupeng','shuting','just','suti','valuest'] #列表#切片print(name[0:])#取到最后print(name[0:-1])#取到倒数第二位print(name[0::1])#从左到右一个一个取print(name 阅读全文
posted @ 2018-06-22 19:19 zhoupeng_L 阅读(125) 评论(0) 推荐(0)
摘要: 1.输出1-100: for循环: while循环: 2.输出1-100的奇数 3.输出1-100,其中50-70不输出 4.break和continue break 跳出整个当前的循环 continue 结束本次循环,继续下次循环 例子: 阅读全文
posted @ 2018-06-22 14:44 zhoupeng_L 阅读(129) 评论(0) 推荐(0)
摘要: 1.单判断猜数字num_of_me = 88guess_num = int (input("please input a number:"))if guess_num == num_of_me: print('bingo')else: print('error')2.简单交互 die_year = 阅读全文
posted @ 2018-06-10 17:47 zhoupeng_L 阅读(151) 评论(0) 推荐(0)