×Ô¶¯½âѹ´óÁ¿Ñ¹ËõÎļþ Python ½Å±¾
֮ǰдÁËÒ»¸ö×Ô¶¯½âѹѹËõÎļþµ½Ñ¹ËõÎļþËùÔÚÎļþ¼ÐµÄ½Å±¾
ºó¸ù¾Ý×Ô¼ºÐèÒª£¬Ð´ÁËÁíÍâÁ½¸ö¡£ÔÀíÒ»Ñù
¶¼ÊÇʹÓÃwinrarµÄÃüÁî
µÚÒ»¸ö½Å±¾Ã»¿¼ÂÇÖܵ½£¬Ö»ÄܽâѹrarÎļþ
¸Ä½øºó¿ÉÒÔÖ§³ÖwinrarÖ§³ÖµÄ¸÷ÖÖÎļþ
°ÑÖ¸¶¨Îļþ¼ÐϵÄÎļþ±£´æµ½Ö¸¶¨Îļþ¼Ð
#rardir.py
import os
import sys
src=sys.argv[1]
dst=sys.argv[2]
format=['rar','zip','7z','ace','arj','bz2','cab','gz','iso','jar','lzh','tar','uue','z']
os.chdir(sys.argv[1])
for file in os.listdir('.'):
if os.path.isfile(file) and (os.path.splitext(file)[1][1:].lower() in format)==True:
#cmd='winrar x -ibck "'+file+'" "'+dst+'\\'+os.path.splitext(file)[0]+'\\"'
cmd='winrar x -ibck "'+file+'" "'+dst+'\\"'
os.system(cmd)
os.remove(file)
print('done '+file)
µÚÒ»¸ö°æ±¾µÄ¸Ä½ø
#rardecmp.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=\'diredel\' to decompress rar files in current directory and delete files\n')
print ('opt=\'mkdel\' to mkdir and delete rar file\n')
exit(0)
#-ibck ,minimized when running
opt=sys.argv[2]
os.chdir(sys.argv[1])
format=['rar','zip','7z','ace','arj','bz2','cab','gz','iso','jar','lzh','tar','uue','z']
for file in os.listdir('.'):
if os.path.isfile(file) and (os.path.splitext(file)[1][1:].lower() in format)==True:
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)
Ïà¹ØÎĵµ£º
ÀµÓºƣ¨http://laiyonghao.com£©
½ñÌ죨2009Äê5ÔÂ31ÈÕ£© OurPNP.org ¸ãÁ˸ö¾Û»á»î¶¯£¬ÅªÁËÊ®¼¸¶þÊ®¸öÈËÔÚ¹ãÖݺ£Öé¹ã³¡µÄÌûá´ôÁËÎå¸öСʱ£¬´´ÏÂÁËÎÒÔÚ K ·¿´ôµÄ×ʱ¼ä¼Í¼¡£Ó¦ËûÃǵÄÑûÇ룬ÎÒ×öÁ˸öÌâΪ¡¶Óà python ¿ìËÙ´î½¨ÍøÓηþÎñÆ÷¡·µÄСÑݽ²£¬ÒòΪÄDZߵĵçÊÓ¾¹È»²»ÄܽӵçÄÔ£¬ËùÒÔ½²µÄʱºòûÓÐÄܹ»²ÎÕÕ PPT À´½²£¬¹Û ......
ÕâÊÇÒ»¸öÎÒÃÇÔÚ´¦ÀíÖÐÎÄʱ, ¾³£Óöµ½µÄÎÊÌâ.
pythonÀïÃæ»ù±¾ÉÏÒª¿¼ÂÇÈýÖÖ±àÂë¸ñʽ
1 Ô´Îļþ±àÂë
ÔÚÎļþÍ·²¿Ê¹ÓÃcodingÉùÃ÷¡£¸æËßpython½âÊÍÆ÷¸Ã´úÂëÎļþËùʹÓõÄ×Ö·û¼¯¡£
#/usr/bin/python
#coding: utf8
2 ÄÚ²¿±àÂë
´úÂëÎļþÖеÄ×Ö·û´®£¬¾¹ýdecodeÒԺ󣬱»×ª»»ÎªÍ³Ò»µÄunicode¸ñʽµÄÄÚ²¿Êý¾Ý£¬ÀàËÆÓÚu'*'¡£unic ......
1.³£Ó÷½·¨£¬²»´ø²ÎÊý
def decator(func):
def inner_func(*args):
args = (i * 2 for i in args)
return func(*args)
return inner_func
@decator
def add(a, ......
PythonÒѾÊÇ3.1°æ±¾ÁË,Óëʱ¾ã½ø¸üн̳Ì.
±¾ÎÄÊʺÏÓÐJava±à³Ì¾ÑéµÄ³ÌÐòÔ±¿ìËÙÊìϤPython
±¾ÎijÌÐòÔÚwindows xp+python3.1a1 ²âÊÔͨ¹ý.
±¾ÎÄÌáµ½µÄidleÖ¸python shell,¼´°²×°pythonºóÄãÔڲ˵¥¿´µ½µÄIDLE(python gui)
ÔÚidleÀïctrl+n¿ÉÒÔ´ò¿ªÒ»¸öд°¿Ú,ÊäÈëÔ´Âëºóctrl+s¿ÉÒÔ±£´æ,f5ÔËÐгÌÐò.
·²´ò¿ªÐ´°¿Ú¼´Ö¸ctrl ......
1.½âÊÍÐÔ ¿ÉÒÔÖ±½Ó´ÓÔ´´úÂëÔËÐгÌÐò.ÔÚ¼ÆËã»úÄÚ²¿,Python½âÊÍÆ÷°ÑÔ´´úÂëת»»³É³ÆÎª×Ö½ÚÂëµÄÖмäÐÎʽ,È»ºóÔÙ°ÑËü·Òë³É¼ÆËã»úʹÓõĻúÆ÷ÓïÑÔ²¢ÔËÐÐ.
2.#·ûºÅºóÃæµÄÄÚÈݶ¼ÊÇ×¢ÊÍ.
3.ÔÚ×Ö·û´®ÖÐÐÐÄ©µÄ'\'±íʾÏÂÒ»ÐеÄÄÚÈݺÍÉÏÒ»ÐÐÊǽÓ×ŵÄ;×Ö·û´®Ç°¼ÓÒ»¸ör±íʾijЩ²»ÐèҪתÒå·ûÄÇÑùµÄÌØ±ð´¦ÀíµÄ×Ö·û´®;ÔÚ´¦ÀíÎı¾ÎļþµÄʱºòÊ ......