diff options
author | 2021-09-09 12:28:13 -0400 | |
---|---|---|
committer | 2021-09-09 12:28:13 -0400 | |
commit | 3d6ba16691512292c239e76c0a9ae373b3982bc2 (patch) | |
tree | ad787b61b4d2ec6e5966d9bb31885e058e913cc2 | |
parent | Add required newline to end of file (diff) |
Change formatting of examples
After some discussion back and forth, I've adjusted how to display
the examples and code bock to be of a more REPL-style.
Additionally, a filler character for the "Center Me!" string is added to
illustrate how exactly in centers it.
This commit also adds some small styling changes.
-rw-r--r-- | bot/resources/tags/string-formatting.md | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/bot/resources/tags/string-formatting.md b/bot/resources/tags/string-formatting.md index 272b96af3..707d19c90 100644 --- a/bot/resources/tags/string-formatting.md +++ b/bot/resources/tags/string-formatting.md @@ -1,25 +1,22 @@ -**String Formatting Mini Language** -The String Formatting Language in Python is a powerful way to tailor the display of strings and other data structures. This string formatting mini language works for f-strings and .format(). +**String Formatting Mini-Language** +The String Formatting Language in Python is a powerful way to tailor the display of strings and other data structures. This string formatting mini language works for f-strings and `.format()`. Take a look at some of these examples! ```py -my_num = 2134234523 -print(f"{my_num:,}") +>>> my_num = 2134234523 +>>> print(f"{my_num:,}") +2,134,234,523 -my_smaller_num = -30.0532234 -print(f"{my_smaller_num:=09.2f}") +>>> my_smaller_num = -30.0532234 +>>> print(f"{my_smaller_num:=09.2f}") +-00030.05 -my_str = "Center me!" -print(f"{my_str:^20}") +>>> my_str = "Center me!" +>>> print(f"{my_str:-^20}") +-----Center me!----- -repr_str = "Spam \t Ham" -print(f"{repr_str!r}") -``` -Results: -``` -2,134,234,523 --00030.05 - Center me! +>>> repr_str = "Spam \t Ham" +>>> print(f"{repr_str!r}") 'Spam \t Ham' ``` **Full Specification & Resources** |