又是一年3月,四六级报名时

又是一年四六级报名,辅导员好懒,让我去挑照片,就是把报名的同学的照片从一个放有所有同学照片的文件夹挑出来,名单是在excel表格里面,这里是去年写的代码,我就在辅导员的电脑上装了个Python,把去年的代码改了下,就搞定了。

昨天写的代码:

# -*- coding: utf-8 -*-
import os,shutil as s
import xlrd
xlsfile = 'temp.xls'
photos = 'imgs'
temphoto='tem6'

data = xlrd.open_workbook(xlsfile)
table1 = data.sheets()[0]

tem6ids = table1.col_values(0)
tem6names = table1.col_values(1)  

for id in tem6ids:
    fpath = os.path.join('C:\\temp',photos,str(id)+'.jpg')
    fpath2 = os.path.join('C:\\temp',temphoto,str(id)+'.jpg')
    if os.path.exists(fpath):
        s.copy(fpath,fpath2)
    else:
        print id
2012-03-21 17:34188pythonxlrd