Printing to stdout in Python: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 1: | Line 1: | ||
=External= | |||
=Internal= | =Internal= | ||
* [[Python_Language#Overview|Python Language]] | * [[Python_Language#Overview|Python Language]] | ||
* [[Python_Code_Examples#Code_Examples|Python Code Examples]] | * [[Python_Code_Examples#Code_Examples|Python Code Examples]] | ||
=Overview= | =Overview= | ||
To send a string followed by new line to <code>stdout</code>: | To send a string followed by new line to <code>stdout</code>: |
Revision as of 19:50, 18 June 2022
External
Internal
Overview
To send a string followed by new line to stdout
:
print('something')
To avoid sending a new line at the end:
print('something', end='.')
print('something', end='')
print()
strips quotes from strings, resolves escaped characters and displays the resulting content:
print('this is a\nmulti-line string')
results in:
this is a
multi-line string
print()
add spaces between its arguments:
print('A', 'B', 'C')
results in:
A B C
Redirect to stderr
print('something', file=sys.stderr)