当前位置:网站首页>图片按日期批量导入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时间戳和日期的相互转换
边栏推荐
- Simple handwritten debounce function
- ROS rviz_ Satellite function package visualizes GNSS track and uses satellite map
- Create a gson object that formats the time zone. JSON parsing time formatting zoneddatetime
- Select trigger event from easyUI drop-down box
- YYGH-7-用户管理
- Idea generates entity classes from database tables
- Teach you how to use UCOS
- JDBC学习(一)——实现简单的CRUD操作
- sql及list去重操作
- EasyUI reset multi condition query
猜你喜欢

AutoCAD C polyline self intersection detection

What is webrtc?

Example of MVVM framework based on kotlin+jetpack

YYGH-8-预约挂号

Yygh-8-appointment registration

MySQL (I) - Installation

CAD二次开发+NetTopologySuite+PGIS 引用多版本DLL问题

Oracle condition, circular statement

Linked list (II) - Design linked list

Introduction to browser tools: think sky browser, team work browser
随机推荐
FPGA - 7系列 FPGA SelectIO -07- 高级逻辑资源之ISERDESE2
Camx架构开UMD、KMD log以及dump图的方式
自定义 cube-ui 弹出框dialog支持多个且多种类型的input框
Parsing ng template with let total in NZ Pagination
AutoCAD C polyline small acute angle detection
Integer promotion and size side byte order
MR-WordCount
cocoapod中的第三方库怎么引用本地头文件
链表(二)——设计链表
Alibaba cloud SMS service (Complete Guide), SMS sending function implementation.
lombok @EqualsAndHashCode 注解如何让对象.equals()方法只比较部分属性
ROS rviz_satellite功能包可视化GNSS轨迹,卫星地图的使用
Ethereum Classic的难度计算|猿创征文
MySQL common functions
Note that JPA uses a custom VO to receive jpql query results
Example of MVVM framework based on kotlin+jetpack
Scripting and programming languages
链表(三)——反转链表
Introduction to openscap
借助nz-pagination中的let-total解析ng-template