# 1 编写 tail -f a.txt |grep 'error' |grep '404'命令,周一默写
# import time
# def tail(filepath,encoding='utf-8'):
# with open(filepath,encoding=encoding)as f:
# f.seek(0,2)
# while True:
# line=f.readline()
# if line:
# yield line
# else:
# time.sleep(0.5)
# def grep(lines,pattern):
# for line in lines:
# if pattern in line:
# # print(line)
# yield line
# g=tail('a.txt')
# g2=grep(g,'error')
# g3=grep(g2,'404')
# for i in g3:
# print(i)
# 2 文件a.txt内容
# apple 10 3
# tesla 100000 1
# mac 3000 2
# lenovo 30000 3
# chicken 10 3
# with open('a.txt','w',encoding='utf-8')as f:
# f.write('apple 10 3\ntesla 100000 1\nmac 3000 2\nlenovo 30000 3\nchicken 10 3')
# 要求使用列表解析,从文件a.txt中取出每一行,做成下述格式
# [{‘name’:'apple','price':10,'count':3},{...},{...},...]
# with open('a.txt', 'r', encoding='utf-8')as f:
# print([{'name':line.strip().split()[0],'price':line.strip().split()[1],'count':line.strip().split()[2]} for line in f])
# for i in [{'name':line.strip().split()[0],'price':line.strip().split()[1],'count':line.strip().split()[2]} for line in f]:
# print(i)
# 3 格式与2一样,但只保留价格大于1000的商品信息
# with open('a.txt',encoding='utf-8')as f:
# for i in [{'name':line.strip().split()[0],'price':line.strip().split()[1],'count':line.strip().split()[2]} for line in f]:
# if int(i['price'])>1000:
# print(i)
# 4 周末大作业(见图):
# 只实现作业要求的查询功能
# 增加,删除,修改功能为选做题

最新文章

  1. Webpack中hash与chunkhash的区别,以及js与css的hash指纹解耦方案
  2. 安装Sublime Text 3插件的方法
  3. 【LeetCode OJ】Word Ladder I
  4. 【转】GridView中页脚汇总显示
  5. [jobdu]二维数组中的查找
  6. textField:shouldChangeCharactersInRange:replacementString:
  7. 多校 Cow Bowling
  8. java.text.DateFormat 多线程并发问题
  9. netData.go 阅读源码
  10. puppet的常用语法
  11. Chrome刷新缓存
  12. MySQL面试题之如何优化一条有问题的SQL语句?
  13. Web大前端面试题-Day1
  14. ELK之elasticsearch6.5集群
  15. 清除 eclipse svn 账号密码
  16. 壮哉大微软,.Net人的春天来了,你准备好了嘛!
  17. python基础——Linux系统下的文件目录结构
  18. react 组件积累
  19. HAproxy-1.6.3 安装部署
  20. java实例三维空间求点之间的距离。。。。

热门文章

  1. (转)java synchronised关键字
  2. ROS导航之参数配置和自适应蒙特卡罗定位
  3. 浏览器配置工具.bat
  4. hdu 4294(bfs)
  5. js和jquery获取父级元素、子级元素、兄弟元素的方法{转}
  6. iOS --转载 NSRange 和 NSString 详解
  7. 面试题思考:Cookie 和 Session的区别
  8. 一起学 Java集合框架、数据结构、泛型
  9. [LintCode] 删除链表中倒数第n个节点
  10. ZOJ 3490 String Successor(模拟)