Here's what I have as a reference. Basically a summary of the Format Specification Mini-Language . This would all go after a : in the f-string curly braces. So if you want a float with 2 decimal place precision, with * as fill and right aligned in a field width of 10 characters you'd do f"{val:*>10.2f}" [[fill]align][sign][#][0][minimumwidth][.precision][type] Fill: Add a character to fill with. Must be followed by Align flag. Align: '<' - Forces the field to be left-aligned within the available space (This is the default.) '>' - Forces the field to be right-aligned within the available space. '=' - Forces the padding to be placed after the sign (if any) but before the digits. This is used for printing fields in the form '+000000120'. This alignment option is only valid for numeric types. '^' - Forces the field to be centered within the available space. Sign: '+' - indicates that a sign should be used for both positive as well as negative numbers '-' - indicates that a sign should be used only for negative numbers (this is the default behavior) ' ' - indicates that a leading space should be used on positive numbers #: Flags alternate numbering formats; binary, octal, and hexadecimal output will be prefixed with '0b', '0o', and '0x', respectively. 0: Zero-padding. Equivalent to fill '=' and character of '0' Minimumwidth: Min width of the field. Precision: Decimal places for floats or max field size for non-numeric types. Type: Integers: 'b' - Binary. Outputs the number in base 2. 'c' - Character. Converts the integer to the corresponding Unicode character before printing. 'd' - Decimal Integer. Outputs the number in base 10. 'o' - Octal format. Outputs the number in base 8. 'x' - Hex format. Outputs the number in base 16, using lower- case letters for the digits above 9. 'X' - Hex format. Outputs the number in base 16, using upper- case letters for the digits above 9. 'n' - Number. This is the same as 'd', except that it uses the current locale setting to insert the appropriate number separator characters. '' (None) - the same as 'd' Floats: 'e' - Exponent notation. Prints the number in scientific notation using the letter 'e' to indicate the exponent. 'E' - Exponent notation. Same as 'e' except it converts the number to uppercase. 'f' - Fixed point. Displays the number as a fixed-point number. 'F' - Fixed point. Same as 'f' except it converts the number to uppercase. 'g' - General format. This prints the number as a fixed-point number, unless the number is too large, in which case it switches to 'e' exponent notation. 'G' - General format. Same as 'g' except switches to 'E' if the number gets to large. 'n' - Number. This is the same as 'g', except that it uses the current locale setting to insert the appropriate number separator characters. '%' - Percentage. Multiplies the number by 100 and displays in fixed ('f') format, followed by a percent sign. '' (None) - similar to 'g', except that it prints at least one digit after the decimal point. Answer from ebdbbb on reddit.com
Python Morsels
pythonmorsels.com › string-formatting
Python f-string tips & cheat sheets - Python Morsels
April 12, 2022 - >>> name = "Trey" >>> print(f"My name is {name}. What's your name?") My name is Trey. What's your name? ... But Python's string formatting syntax also allows us to control the formatting of each of these string components. There is a lot of complexity in Python's string formatting syntax. If you're just here for quick answers, skip to the cheat sheets section.
Fstring
fstring.help › cheat
Python f-string cheat sheet
Type f with precision .n displays n digits after the decimal point. Type g with precision .n displays n significant digits in scientific notation. Trailing zeros are not displayed. ... An empty type is synonymous with d for integers. These format specifications only work on integers (int).
Videos
python f string cheat sheet
19:43
Every F-String Trick In Python Explained - YouTube
09:03
5 Useful f String Tricks - For Python
11:16
Python F-Strings: Advanced Tips and Tricks - YouTube
09:38
5 More Useful F-String Tricks In Python - YouTube
17:00
Python F Strings Explained in 15 Minutes - YouTube
DEV Community
dev.to › amohgodwin › f-strings-the-ultimate-cheatsheet-for-python-string-formatting-3cn
F-Strings: The Ultimate Cheatsheet for Python String Formatting - DEV Community
July 13, 2025 - First, let's briefly look at the older methods f-strings improve upon. ... folder = "/home/user/john/movies" filename = "Big Buck Bunny.mp4" print("The folder name is '" + folder + "' and the filename is '" + filename + "'.") ... All these methods work, but they can be verbose and hard to read, especially with multiple variables. Now, let's see how f-strings can simplify the previous examples.
Cheatography
cheatography.com › brianallan › cheat-sheets › python-f-strings-basics
Python F-Strings Basics Cheat Sheet by BrianAllan - Download free from Cheatography - Cheatography.com: Cheat Sheets For Every Occasion
March 16, 2022 - Contains formulas, tables, and examples showing patterns and options, with the exception of number formatting, for Python's Formatted String Literals -- i.e., F-Strings. ... https://cheatography.com/brianallan/cheat-sheets/python-f-strings-basics/ //media.cheatography.com/storage/thumb/brianallan_python-f-strings-basics.750.jpg
Cheatography
cheatography.com › brianallan › cheat-sheets › python-f-strings-number-formatting
Python F-Strings Number Formatting Cheat Sheet by BrianAllan - Download free from Cheatography - Cheatography.com: Cheat Sheets For Every Occasion
Contains formulas, tables, and examples showing patterns and options focused on number formatting for Python's Formatted String Literals -- i.e., F-Strings.
Top answer 1 of 2
3
Here's what I have as a reference. Basically a summary of the Format Specification Mini-Language . This would all go after a : in the f-string curly braces. So if you want a float with 2 decimal place precision, with * as fill and right aligned in a field width of 10 characters you'd do f"{val:*>10.2f}" [[fill]align][sign][#][0][minimumwidth][.precision][type] Fill: Add a character to fill with. Must be followed by Align flag. Align: '<' - Forces the field to be left-aligned within the available space (This is the default.) '>' - Forces the field to be right-aligned within the available space. '=' - Forces the padding to be placed after the sign (if any) but before the digits. This is used for printing fields in the form '+000000120'. This alignment option is only valid for numeric types. '^' - Forces the field to be centered within the available space. Sign: '+' - indicates that a sign should be used for both positive as well as negative numbers '-' - indicates that a sign should be used only for negative numbers (this is the default behavior) ' ' - indicates that a leading space should be used on positive numbers #: Flags alternate numbering formats; binary, octal, and hexadecimal output will be prefixed with '0b', '0o', and '0x', respectively. 0: Zero-padding. Equivalent to fill '=' and character of '0' Minimumwidth: Min width of the field. Precision: Decimal places for floats or max field size for non-numeric types. Type: Integers: 'b' - Binary. Outputs the number in base 2. 'c' - Character. Converts the integer to the corresponding Unicode character before printing. 'd' - Decimal Integer. Outputs the number in base 10. 'o' - Octal format. Outputs the number in base 8. 'x' - Hex format. Outputs the number in base 16, using lower- case letters for the digits above 9. 'X' - Hex format. Outputs the number in base 16, using upper- case letters for the digits above 9. 'n' - Number. This is the same as 'd', except that it uses the current locale setting to insert the appropriate number separator characters. '' (None) - the same as 'd' Floats: 'e' - Exponent notation. Prints the number in scientific notation using the letter 'e' to indicate the exponent. 'E' - Exponent notation. Same as 'e' except it converts the number to uppercase. 'f' - Fixed point. Displays the number as a fixed-point number. 'F' - Fixed point. Same as 'f' except it converts the number to uppercase. 'g' - General format. This prints the number as a fixed-point number, unless the number is too large, in which case it switches to 'e' exponent notation. 'G' - General format. Same as 'g' except switches to 'E' if the number gets to large. 'n' - Number. This is the same as 'g', except that it uses the current locale setting to insert the appropriate number separator characters. '%' - Percentage. Multiplies the number by 100 and displays in fixed ('f') format, followed by a percent sign. '' (None) - similar to 'g', except that it prints at least one digit after the decimal point.
2 of 2
1
A cheat sheet for f-string would be too short and kind of useless since f-string are super simple. If you want to put a number just do it. Ex. name: str = "Albus Dumbledore" age: int = 116 print(f"Name: {name}, Age: {age}") As you can see, I simply put age (which is an int) inside 2 brackets in the string (don't forget the f) and let Python do it's magic. (If you want you can use the example above as your cheat sheet)
Android Experto
androidexperto.com › home › f-strings: the ultimate cheatsheet for python string formatting
F-Strings: The Ultimate Cheatsheet for Python String Formatt
May 25, 2026 - Python f-strings make string formatting fast, readable, and concise. Introduced in Python 3.6, they let you place variables, expressions, and formatting rules directly inside string literals, avoiding the clutter of older approaches like % formatting or .format(). This cheatsheet covers the ...
Cheatography
cheatography.com › brianallan › cheat-sheets › python-f-strings-basics › pdf pdf
Python F-Strings Basics Cheat Sheet by BrianAllan
Python F-Strings Basics Cheat Sheet ... used by f-string must have different kind of quotes · f'She has {pet['cats']}.' · Formatting: Fill, Align, Width ·...
Alexanderjunge
alexanderjunge.net › blog › til-fstring-formatting
Alexander Junge's website - TIL: f-string formatting - a cheat sheet
I am a big fan of f-strings in Python. If you are not using them yet, you should! f-strings come with a string formatting syntax that makes it very convenient to create nicely formatted strings. For example, you can introduce padding: ... The trouble is that I ALWAYS forget this syntax and need to search online every single time without good hits. BUT: this is now solved thanks to this awesome cheatsheet I discovered today: https://fstring.help/cheat/ 🤩
TechBloat
techbloat.com › home › f-strings: the ultimate cheatsheet for python string formatting
F-Strings: The Ultimate Cheatsheet for Python String Formatt
May 24, 2026 - Introduced in Python 3.6, they ... covers the patterns you’ll use most often: inserting values, formatting numbers and dates, controlling alignment and padding, escaping braces and quotes, and using handy debugging syntax....
Hacker News
news.ycombinator.com › item
Python f-string cheat sheets (2022) | Hacker News
August 22, 2025 - I'm also the author of https://fstring.help/cheat/ (though not of the homepage) and I haven't yet linked back to that new tool. I was surprised to the cheat sheet here today but not the format guesser · At the very least, your tool wasn't able to figure it out and hardcoded most of the number ...