python连接网络打印机脚本

import socket
mysocket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)         
host = "192.168.21.33" 
port = 9100   
try:           
	mysocket.connect((host, port)) #connecting to host
	mysocket.send(b"^XA^A0N,50,50^FO50,50^FDSocket Test^FS^XZ")#using bytes
	mysocket.close () #closing connection
except:
	print("Error with the connection")

扫码关注微信公众号:天天程序员,每天分享程序员故事。更多资源下载尽在天天程序员

你可能感兴趣的:(python)