Since "Z58B" is often manufactured by various vendors (like or Xprinter ), it is best to use the driver provided by the specific manufacturer:
import serial ser = serial.Serial('COM3', 9600, timeout=1) ser.write(b'\x1B\x40') # Initialize printer ser.write(b'Hello Z58B!\n') ser.write(b'\x1D\x56\x00') # Partial cut (if cutter present) ser.close() z58b thermal printer driver