I do some old report conversion and need to add "new page" FF character. What's the syntax to print FF character from Python?
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.