首页 > 代码库 > python编程快速上手之第12章实践项目参考答案(12.13.2)

python编程快速上手之第12章实践项目参考答案(12.13.2)

#! python3
# blankRowInserter.py
import openpyxl,os
os.chdir(C:\\Users\\Administrator\\Python35-32)
n=int(input(rowNum))
m=int(input(insertrowNum))
name=(updatedProduceSales2.xlsx)
wb = openpyxl.load_workbook(name)
wbnew=openpyxl.Workbook()
sheet = wb.get_active_sheet()
sheetnew=wbnew.get_active_sheet()
for rowNum in range(1, sheet.max_row+1):
  if rowNum > n-1:
    for colNum in range(1,sheet.max_column+1):
      produceName = sheet.cell(row=rowNum, column=colNum).value
      sheetnew.cell(row=rowNum+m, column=colNum).value =http://www.mamicode.com/ produceName
  else:
    for colNum in range(1,sheet.max_column+1):
      produceName = sheet.cell(row=rowNum, column=colNum).value
      sheetnew.cell(row=rowNum, column=colNum).value =http://www.mamicode.com/ produceName
  
wbnew.save(blankRowInserter.xlsx)

 

python编程快速上手之第12章实践项目参考答案(12.13.2)