Coding/Python 삽질기2007. 11. 20. 23:34
급하게 파일을 합쳐하 하는 일이 생겨서 만든 파이썬 스크립트이다.
 
기능은 단지 여러개의  파일을 하나로 붙여준는 것 말고는 없다.

#-*- coding: cp949 -*-
# ACopy
# filename : acopy.py
# author    : chobocho at korea.com
# date        : 2007. 11. 20
#
# 여러개의 파일을 붙여 주는 프로그램
import sys
def main(files):
    file_number = len(files)
    target_file = files[1];
        
    target = file(target_file, 'wb')
 
    for idx in range (2, file_number):
        source = file(files[idx], 'rb')
        source_data = source.read()
        source.close()
        target.write(source_data)
    target.close()
   
#-------------------------------------------------------------------------------
# main
if __name__ == "__main__": 
    if len(sys.argv) < 3:
        print "Usage : acopy target source1 [source2]*"
    else:
        main(sys.argv)


'Coding > Python 삽질기' 카테고리의 다른 글

Post it 만들기  (0) 2008.03.04
http://www.pythonchallenge.com...Level1  (1) 2007.09.29
http://www.pythonchallenge.com  (0) 2007.09.28
Posted by chobocho