import os
import win32clipboard as w
import win32con
FileName = os.listdir('D:\\workSpace\\17957\\Reptile\\demo\\imgs')
Front = input("请输入前置文件名:")
Num = int(input("请输入文件数目:"))
End = input("请输入扩展名:")
FilePosition = os.getcwd()
def settext(aString):
w.OpenClipboard()
w.EmptyClipboard()
w.SetClipboardData(win32con.CF_UNICODETEXT, aString)
w.CloseClipboard()
while 1 == 1:
Start = input("请输入起始编号:")
Name = Front + Start + '.' + End
position = FileName.index(Name)
Text = ''
for i in range(Num):
Name = FileName[i + position]
Long = FilePosition + '\\' + Name
Super = '<table><img src=\'' + Long + '\'width=\'300\' height=\'200\'>'
Text = Text + Super + '\n'
settext(Text)
print(Text)
运行结果
<table><img src='D:\workSpace\17957\Reptile\demo\图片_1066.jpg'width='300' height='200'>
<table><img src='D:\workSpace\17957\Reptile\demo\图片_1067.jpg'width='300' height='200'>
<table><img src='D:\workSpace\17957\Reptile\demo\图片_1068.jpg'width='300' height='200'>
<table><img src='D:\workSpace\17957\Reptile\demo\图片_1069.jpg'width='300' height='200'>
<table><img src='D:\workSpace\17957\Reptile\demo\图片_107.jpg'width='300' height='200'>
将运行的结果复制下来
打开office
找到需要复制的起始单元格,右击复制,找到选择性复制里面的unicode复制
将运行结果放到里面