I have a raspberry pi that is connected to an USB printer.
When pressing a physical button a python script is executed. The script itself is very simple.
In the end the results should be printed using the usb printer.
There are no other peripherals except the printer connected to the raspberry pi. Is there an easy way to print out of the python script?
Pls note: I don’t want to print a document or a file but only the value of a variable calculated by the script.
If there is an easy way to do it with a different programming language, that’s of course also viable.
Thank you
there are a few packages for that purpose. the first one can only be used with espon printers, but the others should be fine with any type of printer:

python-escpos
pkipplib
win32print
How do I Hard print out of my python script