aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ChrisJL <[email protected]>2021-09-09 17:37:50 +0100
committerGravatar GitHub <[email protected]>2021-09-09 17:37:50 +0100
commit2c6e51fa7a81437fdddc60e6a616ae33218837dd (patch)
tree7fe26a57043c0ffdcf99a48014cc58c3390b94cd
parentMerge pull request #1813 from python-discord/declare-talentpool-cache-on-startup (diff)
parentMerge branch 'main' into string-formatting-tag (diff)
Merge pull request #1819 from python-discord/string-formatting-tag
Add string-formatting tag
-rw-r--r--bot/resources/tags/string-formatting.md24
1 files changed, 24 insertions, 0 deletions
diff --git a/bot/resources/tags/string-formatting.md b/bot/resources/tags/string-formatting.md
new file mode 100644
index 000000000..707d19c90
--- /dev/null
+++ b/bot/resources/tags/string-formatting.md
@@ -0,0 +1,24 @@
+**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:,}")
+2,134,234,523
+
+>>> my_smaller_num = -30.0532234
+>>> print(f"{my_smaller_num:=09.2f}")
+-00030.05
+
+>>> my_str = "Center me!"
+>>> print(f"{my_str:-^20}")
+-----Center me!-----
+
+>>> repr_str = "Spam \t Ham"
+>>> print(f"{repr_str!r}")
+'Spam \t Ham'
+```
+**Full Specification & Resources**
+[String Formatting Mini Language Specification](https://docs.python.org/3/library/string.html#format-specification-mini-language)
+[pyformat.info](https://pyformat.info/)