我已经成功地写小代码,但我的技能是非常差的(虽然我尽我所能)需要一些精度在Python
我想打印从相机dowloaded图像。但是,虽然相机会每30秒拍摄一张图像,但我想随机打印一段时间(3到10分钟之间)图像
有人可以帮我吗?非常感谢
这是我迄今为止所做的代码。
monRep = "***/folder1"
import os, mimetypes, random, glob
while True:
fpaths = []
for fname in os.listdir(monRep):
fpath = os.path.join(monRep, fname)
if os.path.isfile(fpath):
mt = mimetypes.guess_type(fpath)[0]
ext = os.path.splitext(fpath)[1]
if mt: mt = mt.split('/')[0].lower()
else: mt = False
#if ext.lower() in ('.bmp','.pict', '.JPG', '.jpg', '.pdf'): mt = 'image'
if mt in ('image',): fpaths.append(fpath)
for fpath in fpaths:
newpath = fpath.replace('***/Folder1/','***/Folder2/')
os.rename(fpath,newpath)
command = "lpr "+newpath
print (command)
os.system(command)
import time
time.sleep (1)
directory='***/Folder2/'
os.chdir(directory)
files=glob.glob('*.JPG')
for filename in files:
os.unlink(filename)
?打印文件名,在图像处理器中显示图像或将其发送到打印机? – RickyA
对不起:把它发送到打印机谢谢 – NocNockie
好吧,那么你的脚本中现在不工作? – RickyA