diff options
author | 2021-09-09 10:31:48 -0400 | |
---|---|---|
committer | 2021-09-09 10:31:48 -0400 | |
commit | 108fb5d3dfc76c78d51126660ce891f9d1ee10eb (patch) | |
tree | 78e9e90cada3b7cd10ce9f7c3a8a1536affad0ef | |
parent | Add support for `!infraction last` (#1804) (diff) |
Add string-formatting tag
Adds a tag to show the string formatting mini language
-rw-r--r-- | bot/resources/tags/string-formatting.md | 27 |
1 files changed, 27 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..fba5577b8 --- /dev/null +++ b/bot/resources/tags/string-formatting.md @@ -0,0 +1,27 @@ +**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_smaller_num = -30.0532234 +print(f"{my_smaller_num:=09.2f}") + +my_str = "Center me!" +print(f"{my_str:^20}") + +repr_str = "Spam \t Ham" +print(f"{repr_str!r}") +``` +Results: +``` +2,134,234,523 +-00030.05 + Center me! +'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/)
\ No newline at end of file |