摘要: 装饰器实例:为网站的多个页面添加登陆认证 阅读全文
posted @ 2018-03-26 08:15 Lief_1997 阅读(111) 评论(0) 推荐(0)
摘要: 装饰器原则 1. 不能修改被装饰函数的源代码 2. 不能修改被装饰函数的调用方式 import time def timer(func): # func = test1、test2 def deco(*args, **kwargs): start_time = time.time() func(*args, **kwargs) # test1、te... 阅读全文
posted @ 2018-03-26 08:13 Lief_1997 阅读(108) 评论(0) 推荐(0)
摘要: 函数的使用、局部变量、局部作用域、高阶函数、递归 阅读全文
posted @ 2018-03-26 08:08 Lief_1997 阅读(164) 评论(0) 推荐(0)
摘要: 1 # 文件的操作 2 3 4 ''' 5 # 以只读模式打开 6 import sys, time 7 f = open('lyrics.txt', 'r') 8 9 print(f.read()) # 读取整个文件 10 print(f.readline()) # 读取文件中的一行 11 print(f.readlines()) # 将整个文件的所有行读出 12... 阅读全文
posted @ 2018-03-26 08:06 Lief_1997 阅读(166) 评论(0) 推荐(0)
摘要: 字符编码 encode、decode 阅读全文
posted @ 2018-03-17 12:09 Lief_1997 阅读(119) 评论(0) 推荐(0)
摘要: 集合的所有操作 1 # 集合的所有操作 2 3 list_1 = [1, 2, 3, 4, 5, 6] 4 list_2 = [3, 4, 5, 6, 7, 8] 5 6 list_1 = set(list_1) 7 list_2 = set(list_2) 8 9 print(list_1, list_2) 10 # 取并集 11 print(list_1 | lis... 阅读全文
posted @ 2018-03-17 12:08 Lief_1997 阅读(192) 评论(0) 推荐(0)
摘要: 1 #购物车程序 2 3 salary=input("请输入你本月的工资: ") 4 if salary.isdigit(): 5 salary = int(salary) 6 goods=['Coco(12 yuan)','Sprite(13 yuan)','Notebook(5 yuan)','iPhone(8888 yuan)','Earphone(... 阅读全文
posted @ 2018-03-17 12:05 Lief_1997 阅读(198) 评论(0) 推荐(0)
摘要: 1 #字符串的所有操作 2 3 name = 'Lief \tis a {type} student.' 4 print(name.center(39,'-')) # 将字符串放置在另一个重复字符串的中间 5 print(name.endswith("f")) # 判断是否以某个指定字符串结尾 6 print(name.expandtabs(tabsize = 9)) # 在... 阅读全文
posted @ 2018-03-14 21:08 Lief_1997 阅读(205) 评论(0) 推荐(0)
摘要: #购物车程序 1 '''启动程序后让用户输入工资,然后打印商品列表 2 用户根据编号选择购买的商品 3 用户的钱足够就直接扣钱,不够就提醒 4 可随时退出,退出时打印已购买商品和余额''' 5 6 salary=input("请输入你本月的工资: ") 7 goods=['1.可乐(12)','2.雪碧(13)','3.Notebook(5)','4.iPhone(8888)',... 阅读全文
posted @ 2018-03-12 10:00 Lief_1997 阅读(179) 评论(0) 推荐(0)
摘要: #登陆程序 #Login——by Lief username='Lief' password='88888888' count=0 while count<3: UN=input('Please type your username here: ') PW=input('Please type your password here: ') if UN==username... 阅读全文
posted @ 2018-03-11 21:34 Lief_1997 阅读(131) 评论(0) 推荐(0)