易截截图软件、单文件、免安装、纯绿色、仅160KB

解压文件夹中的压缩文件 Python脚本

下载了很多压缩文件,就写了一个脚本
在Python中使用winrar命令,所以一般压缩文件都支持
有些压缩文件Python中还没有相应的库
你得先把winrar添加到path环境变量中
把代码保存为rar.py
在dos下使用,如:rar.py "D:\A B\C" mkdir
#rar.py
#decompress with winrar
#arguments :filename directory opt
# opt='mkdir' to create directory with the correspond filename
# opt='direct' to decompress rar files in current directory
# opt='mk&del' to mkdir and delete rar file
import os
import sys
if len(sys.argv)!=3:
print ('wrong arguments\n')
print ('rar.py directory opt\n')
print ('opt=\'mkdir\' to create directory with the correspond filename\n')
print ('opt=\'direct\' to decompress rar files in current directory\n')
print ('opt=\'mk&del\' to mkdir and delete rar file\n')
exit(0)
#-ibck ,minimized when running
opt=sys.argv[2]
os.chdir(sys.argv[1])
for file in os.listdir('.'):
if os.path.isfile(file) and os.path.splitext(file)[1]=='.rar':
if opt=='mkdir':
cmd='winrar x -ibck "'+file+'"'+' "'+os.path.splitext(file)[0]+'"\\'
os.system(cmd)
elif opt=='direct':
cmd='winrar x -ibck "'+file+'"'
os.system(cmd)
elif opt=='mkdel':
cmd='winrar x -ibck "'+file+'"'+' "'+os.path.splitext(file)[0]+'"\\'
os.system(cmd)
os.remove(file)
else :
print('wrong option')



相关文档:

python minidom 写xml示例

以下是一个通过minidom模块写文件的完整示例,是在最近做的项目Walle上面用到的,这个示例的目的是生成一个如下的格式的xml,文件格式为无BOM utf-8。
生成xml文件格式:
<?xml version="1.0" encoding="utf-8"?> 
<coverages> 
    <coverage> 
    ......

python 中minidom解析xml

python 中minidom解析xml
2009年06月26日 星期五 08:40
下面只列出一些常用的方法属性,如果要查看更多的方法, 可以去看文件minidom如何实现的。
获得Document对象
法一:
import xml.dom.minidom as m_dom
doc1 = m_dom.getDOMImplementation().createDocument(None, "root1", None)
doc1.documentElement.toxml(e ......

Python装饰器

一颗语法糖——装饰器
理论不去管,只管能办事:
1.  我要让一个函数在执行的时候,去做一些事情,比如,我要看看这些函数是不是有docstring,将这个功能拿出来,定义一个装饰器:
def showmedoc(func):
     if func.__doc__:
        & ......

使用python操作串口

一、
为了使用python操作串口,首先需要下载相关模块:
1. pyserial (http://pyserial.wiki.sourceforge.net/pySerial)
2. pywin32 (http://sourceforge.net/projects/pywin32/)
二、
google “python 串口 操作”关键字,找到相关python代码,
我是从http://currentlife.blog.sohu.com/53741351.html页面上 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号