dawn-liu

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2018年7月12日

摘要: subprocess可以根据命令的结果,正确的或者错误的分开存放 存放正确的结果 存放错误的结果 实现命令的过滤例如 tasklist|findstr python import subprocess obj1=subprocess.Popen('tasklist',shell=True, stdo 阅读全文
posted @ 2018-07-12 12:24 dawn-liu 阅读(116) 评论(0) 推荐(0) 编辑

摘要: shutil模块:高级的文件,文件夹,压缩包处理 拷贝内容 # shutil.copyfileobj(open('example.ini','r'),open('example.new','w')) #目标文件无需存在 拷贝文件 # shutil.copyfile('example.ini','ex 阅读全文
posted @ 2018-07-12 11:50 dawn-liu 阅读(480) 评论(0) 推荐(0) 编辑

摘要: 命令 grep -rl 'python' 路径 :在一个目录下面找到含有字符串 python 内容的文件 通过一个命令来实现查找字符串的效果 一装饰器:给生成器一个初始化 def init(func): def inner(*args,**kwargs): res=func(*args,**kwar 阅读全文
posted @ 2018-07-12 11:20 dawn-liu 阅读(534) 评论(0) 推荐(0) 编辑

摘要: 生成器:是自定义的迭代器(自己用python代码写的迭代器),函数中见到yield的就是生成器 那么yield前后的变量又该怎么理解 看例子一 例子一打印结果为: xincheng ready to count 现在的列表是[] xincheng start to count 1 现在的列表是['1 阅读全文
posted @ 2018-07-12 10:13 dawn-liu 阅读(521) 评论(0) 推荐(0) 编辑