|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#打开要处理的EXCEL文件
file=input("请输入要处理的文件:")
bk=xlrd.open_workbook(file,formatting_info=True)
#容错处理
try:
sh=bk.sheet_by_index(0)
except:
print("no sheet in %s named sheet" %file)
#获取行数与列数:
nrows=sh.nrows
ncols=sh.ncols
#写入EXCEL表格
wb=xlwt.Workbook() #建立一个EXCEL工作薄,并打开它。
sheet4=wb.add_sheet("考场人数") #添加一个工作表。
#写入考场人数
for i in range(0,nrows):
for c in range(0,ncols):
sheet4.write(sh.cell(i,c).value)
#print(sh.cell(i,c).value)
运行时出现:TypeError: write() missing 1 required positional argument: 'c'
但是打印print(sh.cell(i,c).value)时就会正常运行!
求指正 |
|