python使用xlrd模块操作excel文件,表的内容类似这样:
python代码:
#!/usr/bin/python
#site: www.jb200.com
#
import xlrd
data = xlrd.open_workbook('pro.xls')
table = data.sheets()[0]
nrows = table.nrows
ncols = table.ncols
print '<?php'
print '$unitSkillConfig = array('
for i in range(1,nrows):
print '%d=>narray('%(table.row_values(i)[0])
count = 0
while (1):
print '%d=>narray(' %(count)
print ''skill_id'=>%d,'%(table.row_values(i)[count+1])
print ''unlock_level'=>%d,),' %(0)
count=count+1
if (count + 1>= ncols):
break
print '),'
print ');'