@@ -186,6 +186,26 @@ msgid ""
186186">>> repr((x, y, ('spam', 'eggs')))\n"
187187"\" (32.5, 40000, ('spam', 'eggs'))\" "
188188msgstr ""
189+ ">>> s = 'Witaj, świecie.'\n"
190+ ">>> str(s)\n"
191+ "'Witaj, świecie.'\n"
192+ ">>> repr(s)\n"
193+ "\" 'Witaj, świecie.'\" \n"
194+ ">>> str(1/7)\n"
195+ "'0.14285714285714285'\n"
196+ ">>> x = 10 * 3.25\n"
197+ ">>> y = 200 * 200\n"
198+ ">>> s = 'Wartość x to ' + repr(x) + ', i y to ' + repr(y) + '...'\n"
199+ ">>> print(s)\n"
200+ "Wartość x to 32.5, i y to 40000...\n"
201+ ">>> # repr() ciągu znaków dodaje cudzysłów i backslashe:\n"
202+ ">>> hello = 'witaj, świecie\\ n'\n"
203+ ">>> hellos = repr(hello)\n"
204+ ">>> print(hellos)\n"
205+ "'witaj, świecie\\ n'\n"
206+ ">>> # argumentem repr() może być dowolny obiekt Pythona:\n"
207+ ">>> repr((x, y, ('szynka', 'jajka')))\n"
208+ "\" (32.5, 40000, ('szynka', 'jajka'))\" "
189209
190210msgid ""
191211"The :mod:`string` module contains a :class:`~string.Template` class that "
@@ -226,6 +246,9 @@ msgid ""
226246">>> print(f'The value of pi is approximately {math.pi:.3f}.')\n"
227247"The value of pi is approximately 3.142."
228248msgstr ""
249+ ">>> import math\n"
250+ ">>> print(f'Wartość pi wynosi w przybliżeniu {math.pi:.3f}.')\n"
251+ "Wartość pi wynosi w przybliżeniu 3,142."
229252
230253msgid ""
231254"Passing an integer after the ``':'`` will cause that field to be a minimum "
@@ -244,6 +267,13 @@ msgid ""
244267"Jack ==> 4098\n"
245268"Dcab ==> 7678"
246269msgstr ""
270+ ">>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 7678}\n"
271+ ">>> for name, phone in table.items():\n"
272+ "... print(f'{name:10} ==> {phone:10d}')\n"
273+ "...\n"
274+ "Sjoerd ==> 4127\n"
275+ "Jack ==> 4098\n"
276+ "Dcab ==> 7678"
247277
248278msgid ""
249279"Other modifiers can be used to convert the value before it is formatted. ``'!"
@@ -261,6 +291,11 @@ msgid ""
261291">>> print(f'My hovercraft is full of {animals!r}.')\n"
262292"My hovercraft is full of 'eels'."
263293msgstr ""
294+ ">>> animals = 'węgorze'\n"
295+ ">>> print(f'Na moim poduszkowcu są {animals}.')\n"
296+ "Na moim poduszkowcu są węgorze.\n"
297+ ">>> print(f'Na moim poduszkowcu są {animals!r}.')\n"
298+ "Na moim poduszkowcu są 'węgorze'."
264299
265300msgid ""
266301"The ``=`` specifier can be used to expand an expression to the text of the "
@@ -353,6 +388,10 @@ msgid ""
353388"... 'Dcab: {0[Dcab]:d}'.format(table))\n"
354389"Jack: 4098; Sjoerd: 4127; Dcab: 8637678"
355390msgstr ""
391+ ">>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678}\n"
392+ ">>> print('Jack: {0[Jack]:d}; Sjoerd: {0[Sjoerd]:d}; '\n"
393+ "... 'Dcab: {0[Dcab]:d}'.format(table))\n"
394+ "Jack: 4098; Sjoerd: 4127; Dcab: 8637678"
356395
357396msgid ""
358397"This could also be done by passing the ``table`` dictionary as keyword "
@@ -367,6 +406,10 @@ msgid ""
367406"format(**table))\n"
368407"Jack: 4098; Sjoerd: 4127; Dcab: 8637678"
369408msgstr ""
409+ ">>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678}\n"
410+ ">>> print('Jack: {Jack:d}; Sjoerd: {Sjoerd:d}; Dcab: {Dcab:d}'."
411+ "format(**table))\n"
412+ "Jack: 4098; Sjoerd: 4127; Dcab: 8637678"
370413
371414msgid ""
372415"This is particularly useful in combination with the built-in function :func:"
@@ -479,6 +522,12 @@ msgid ""
479522">>> '3.14159265359'.zfill(5)\n"
480523"'3.14159265359'"
481524msgstr ""
525+ ">>> '12'.zfill(5)\n"
526+ "'00012'\n"
527+ ">>> '-3.14'.zfill(7)\n"
528+ "'-003.14'\n"
529+ ">>> '3.14159265359'.zfill(5)\n"
530+ "'3.14159265359'"
482531
483532msgid "Old string formatting"
484533msgstr "Stare formatowanie ciągów znaków"
0 commit comments