I do some old report conversion and need to add "new page" FF character. What's the syntax to print FF character from Python?
Sometimes abbreviated as FF, form feed is a button or command on the printer that allows the advancement of a printer page. This feature was frequently used on dot matrix printers since nearly all of them used continuous feed paper rather than single sheets.
Auto FF. Off*/On. Allows you to print the remaining data without pressing Go.
Like this *Wikipedia article says Form Feed (FF) has decimal value 12 in ASCII. Which is 0x0c
in hex:
Form feed is a page-breaking ASCII control character. It forces the printer to eject the current page and to continue printing at the top of another. Often, it will also cause a carriage return. The form feed character code is defined as 12 (0xC in hexadecimal) (..) In the C programming language (and other languages derived from C), the form feed character is represented as
'\f'
.
So you can:
print('\x0c',end='')
Or you can use - like @martineau says - use '\f'
:
print('\f',end='')
The end=''
is used to prevent Python from printing an additional new line after the form feed character.
Note that it depends on the console (or the device that receives the stream) how the Form Feed is handled. Some consoles might ignore it. Others print a few blank lines, and a printer might for instance decide to start a new page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With