当前位置:网站首页>图片按日期批量导入WPS表格
图片按日期批量导入WPS表格
2022-06-28 06:19:00 【君王的羔羊】
批量获取图片创建日期
import os
import time
import xlsxwriter
path = "testpic"
file = '数据' + '.xlsx' # 保存表格名
i=1
workbook = xlsxwriter.Workbook(file)
worksheet = workbook.add_worksheet('sheet1')
list =os.listdir(path)
for pic in list:
timeStamp=os.path.getmtime(r"F:\Python\testpic\%s"%pic)
timeArray = time.localtime(timeStamp)
otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
worksheet.write(f'A{
i}',otherStyleTime)
i+=1
workbook.close()
测试图片
获取创建时间并填入表格
批量导入图片
import xlsxwriter
import os
file = 'importpicure' + '.xlsx' # 保存表格名
list =os.listdir("testpic")
print(list)
i=1
workbook = xlsxwriter.Workbook(file)
worksheet = workbook.add_worksheet('sheet1')
for pic in list:
worksheet.insert_image(f'A{
i}', f'testpic/{
list[i-1]}',{
'x_scale': 0.0705, 'y_scale': 0.1015, 'x_offset': 0, 'y_offset': 0}) # 指定A列,x、y为缩放比例
i=i+1
workbook.close()
最终效果图

【参考资料】
python系统路径占位符timeStamp=os.path.getmtime(r"F:\Python\testpic\%s"%pic)
python 使用xlsxwriter循环向excel中插入数据和图片的操作
python将时间戳转变成时间_Python时间戳和日期的相互转换
边栏推荐
- 报错--解决core-js/modules/es.error.cause.js报错
- Use of JDBC
- FPGA - 7系列 FPGA SelectIO -07- 高级逻辑资源之ISERDESE2
- MySQL (II) - basic operation
- 移动广告发展动向:撬动存量,精细营销
- idea根据数据库表生成实体类
- Use the SQL SELECT count distinct query statement to count the total number of unique values of a field in the database
- Promotion intégrale et ordre des octets de fin de taille
- AutoCAD C polyline small acute angle detection
- Configure redis from 0
猜你喜欢

慢内容广告:品牌增长的长线主义

Independent station sellers are using the five e-mail marketing skills, do you know?

Small ball playing

高质量国产立体声编解码器CJC8988,Pin to Pin替代WM8988

Exception handling (I) -- null pointer and array index out of bounds

Caused by: com. fasterxml. jackson. databind. exc.InvalidDefinitionException: Cannot construct instance

ES9023音频解码芯片的工作原理

报错--解决core-js/modules/es.error.cause.js报错

How popular are FB and WhatsApp mass messages in 2022?

FPGA - 7系列 FPGA SelectIO -08- 高级逻辑资源之OSERDESE2
随机推荐
JDBC learning (I) -- implementing simple CRUD operations
Oracle fundamentals summary
【Paper Reading-3D Detection】Fully Convolutional One-Stage 3D Object Detection on LiDAR Range Images
基本类型和包装类的区别
idea创建类时自动添加注释
整型提昇和大小端字節序
Sklearn Feature Engineering (summary)
Introduction to openscap
Object对象转 List集合
Linked list (II) - Design linked list
创建格式化时间,格式化时区的gson对象。json解析时间格式化 ZonedDateTime
What are the advantages of e-mail marketing? Why do sellers of shopline independent station attach so much importance to it?
Yygh-7-user management
阿里云短信服务(完整指南),短信发送功能实现。
手把手教你用Ucos
Enum
YYGH-BUG-02
cocoapod中的第三方库怎么引用本地头文件
Paper recommendation: efficientnetv2 - get smaller models and faster training speed through NAS, scaling and fused mbconv
windows上安装redis并永久修改密码,及ssm框架集成redis