Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2b73660

Browse files
committed
Fix markup in inputoutput.rst.
1 parent 77845ce commit 2b73660

1 file changed

Lines changed: 17 additions & 16 deletions

File tree

Doc/tutorial/inputoutput.rst

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,18 @@ Here are two ways to write a table of squares and cubes::
103103
(Note that in the first example, one space between each column was added by the
104104
way :func:`print` works: it always adds spaces between its arguments.)
105105

106-
This example demonstrates the :meth:`rjust` method of string objects, which
107-
right-justifies a string in a field of a given width by padding it with spaces
108-
on the left. There are similar methods :meth:`ljust` and :meth:`center`. These
109-
methods do not write anything, they just return a new string. If the input
110-
string is too long, they don't truncate it, but return it unchanged; this will
111-
mess up your column lay-out but that's usually better than the alternative,
112-
which would be lying about a value. (If you really want truncation you can
113-
always add a slice operation, as in ``x.ljust(n)[:n]``.)
114-
115-
There is another method, :meth:`zfill`, which pads a numeric string on the left
116-
with zeros. It understands about plus and minus signs::
106+
This example demonstrates the :meth:`str.rjust` method of string
107+
objects, which right-justifies a string in a field of a given width by padding
108+
it with spaces on the left. There are similar methods :meth:`str.ljust` and
109+
:meth:`str.center`. These methods do not write anything, they just return a
110+
new string. If the input string is too long, they don't truncate it, but
111+
return it unchanged; this will mess up your column lay-out but that's usually
112+
better than the alternative, which would be lying about a value. (If you
113+
really want truncation you can always add a slice operation, as in
114+
``x.ljust(n)[:n]``.)
115+
116+
There is another method, :meth:`str.zfill`, which pads a numeric string on the
117+
left with zeros. It understands about plus and minus signs::
117118

118119
>>> '12'.zfill(5)
119120
'00012'
@@ -128,16 +129,16 @@ Basic usage of the :meth:`str.format` method looks like this::
128129
We are the knights who say "Ni!"
129130

130131
The brackets and characters within them (called format fields) are replaced with
131-
the objects passed into the :meth:`~str.format` method. A number in the
132+
the objects passed into the :meth:`str.format` method. A number in the
132133
brackets can be used to refer to the position of the object passed into the
133-
:meth:`~str.format` method. ::
134+
:meth:`str.format` method. ::
134135

135136
>>> print('{0} and {1}'.format('spam', 'eggs'))
136137
spam and eggs
137138
>>> print('{1} and {0}'.format('spam', 'eggs'))
138139
eggs and spam
139140

140-
If keyword arguments are used in the :meth:`~str.format` method, their values
141+
If keyword arguments are used in the :meth:`str.format` method, their values
141142
are referred to by using the name of the argument. ::
142143

143144
>>> print('This {food} is {adjective}.'.format(
@@ -195,8 +196,8 @@ notation. ::
195196
>>> print('Jack: {Jack:d}; Sjoerd: {Sjoerd:d}; Dcab: {Dcab:d}'.format(**table))
196197
Jack: 4098; Sjoerd: 4127; Dcab: 8637678
197198

198-
This is particularly useful in combination with the new built-in :func:`vars`
199-
function, which returns a dictionary containing all local variables.
199+
This is particularly useful in combination with the built-in function
200+
:func:`vars`, which returns a dictionary containing all local variables.
200201

201202
For a complete overview of string formatting with :meth:`str.format`, see
202203
:ref:`formatstrings`.

0 commit comments

Comments
 (0)