python向打印机发送数据(3)--
短信预约 -IT技能 免费直播动态提醒
#!/usr/local/bin/python2.7
# encoding: utf-8
import parallel
import time
import logging
from logging.handlers import TimedRotatingFileHandler
def lpt_data_printer(title,txt):
printer=open("LPT1", "wb")
printer.write(txt)
printer.close()
print u"正在运行第"+str(count)+u"次"
looger.info(u"正在运行第 %s 次" % str(count))
def hello(count):
if count%6==1:
f = open(r"D:\test\FP00001.txt")
lines1 = f.read()
f.close()
lpt_data_printer("lines",lines1)
elif count%6==2:
f = open(r"D:\test\FP00002.txt")
lines2 = f.read()
f.close()
lpt_data_printer("lines",lines2)
elif count%6==3:
f = open(r"D:\test\FP00003.txt")
lines3 = f.read()
f.close()
lpt_data_printer("lines",lines3)
elif count%6==4:
f = open(r"D:\test\FP00004.txt")
lines4 = f.read()
f.close()
lpt_data_printer("lines",lines4)
elif count%6==5:
f = open(r"D:\test\FP00005.txt")
lines5 = f.read()
f.close()
lpt_data_printer("lines",lines5)
elif count%6==0:
f = open(r"D:\test\FP00006.txt")
lines6 = f.read()
f.close()
lpt_data_printer("lines",lines6)
if __name__ == '__main__':
looger = logging.getLogger('LPTPrint')
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
LogHandLer=TimedRotatingFileHandler(r'E:\count.log',when="midnight")
LogHandLer.setFormatter(formatter)
looger.addHandler(LogHandLer)
looger.setLevel(logging.INFO)
count=1
while(1):
hello(count)
count = count +1
f = open(r"D:\time.txt")
line = f.read()
time.sleep(int(line))
f.close()
# encoding: utf-8
import parallel
import time
import logging
from logging.handlers import TimedRotatingFileHandler
def lpt_data_printer(title,txt):
printer=open("LPT1", "wb")
printer.write(txt)
printer.close()
print u"正在运行第"+str(count)+u"次"
looger.info(u"正在运行第 %s 次" % str(count))
def hello(count):
if count%6==1:
f = open(r"D:\test\FP00001.txt")
lines1 = f.read()
f.close()
lpt_data_printer("lines",lines1)
elif count%6==2:
f = open(r"D:\test\FP00002.txt")
lines2 = f.read()
f.close()
lpt_data_printer("lines",lines2)
elif count%6==3:
f = open(r"D:\test\FP00003.txt")
lines3 = f.read()
f.close()
lpt_data_printer("lines",lines3)
elif count%6==4:
f = open(r"D:\test\FP00004.txt")
lines4 = f.read()
f.close()
lpt_data_printer("lines",lines4)
elif count%6==5:
f = open(r"D:\test\FP00005.txt")
lines5 = f.read()
f.close()
lpt_data_printer("lines",lines5)
elif count%6==0:
f = open(r"D:\test\FP00006.txt")
lines6 = f.read()
f.close()
lpt_data_printer("lines",lines6)
if __name__ == '__main__':
looger = logging.getLogger('LPTPrint')
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
LogHandLer=TimedRotatingFileHandler(r'E:\count.log',when="midnight")
LogHandLer.setFormatter(formatter)
looger.addHandler(LogHandLer)
looger.setLevel(logging.INFO)
count=1
while(1):
hello(count)
count = count +1
f = open(r"D:\time.txt")
line = f.read()
time.sleep(int(line))
f.close()
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341