Python编程快速上手让繁琐工作自动化第13章实践项目空行插入程序
2021/9/5 11:06:27
本文主要是介绍Python编程快速上手让繁琐工作自动化第13章实践项目空行插入程序,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
import openpyxl,os
os.chdir('D://')
a = input('输入文件名:')
n = eval(input('第N行开始?'))
m = eval(input('插入M行?'))
wb = openpyxl.load_workbook(a)
sheet = wb.active
i = sheet.max_row
if n >= i:
print('超出行数!最大行数为' + str(i))
while i >= n:
for j in range(1,sheet.max_column+1):
sheet.cell(row=i+m,column=j).value = sheet.cell(row=i,column=j).value
i -= 1
for q in range(n+1,n+m+1):
for j in range(1,sheet.max_column+1):
sheet.cell(row=q,column=j).value = ''
wb.save(a)
print('Done!')
这篇关于Python编程快速上手让繁琐工作自动化第13章实践项目空行插入程序的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-09-27使用python 将ETH账户的资产打散
- 2024-09-26Python编程基础
- 2024-09-2610 种方法写出更好的 Python 代码
- 2024-09-25Python编程基础详解
- 2024-09-25Python编程入门教程
- 2024-09-25从零开始使用Python构建LLaMA 3
- 2024-09-23Python中理解和使用树形结构的简单教程
- 2024-09-23Python 编程基础入门
- 2024-09-18初探Python股票自动化交易:入门指南
- 2024-09-18Python量化入门:轻松掌握量化分析基础与实战