About 380,000 results
Open links in new tab
  1. How to print formatted string in Python3? - Stack Overflow

    Nov 11, 2014 · Even though I don't know which exception you get, you can maybe try to use the format function instead: print ("So, you're {0} old, {1} tall and {2} heavy.".format(age, height, weight))

  2. Python - Output Formatting - GeeksforGeeks

    Dec 16, 2024 · Python’s string methods such as str.center (), str.ljust () and str.rjust () provide straightforward ways to format strings by aligning them within a specified width.

  3. Python String Formatting – How to format String?

    Aug 21, 2024 · There are five different ways to perform string formatting in Python. Formatting with % Operator. Formatting with format () string method. Formatting with string literals, called f-strings. Formatting with center () string method.

  4. 7. Input and Output — Python 3.13.3 documentation

    2 days ago · Formatted string literals (also called f-strings for short) let you include the value of Python expressions inside a string by prefixing the string with f or F and writing expressions as {expression}.

  5. Python String format () Method - W3Schools

    Definition and Usage The format() method formats the specified value (s) and insert them inside the string's placeholder. The placeholder is defined using curly brackets: {}. Read more about the placeholders in the Placeholder section below. The format() method returns the formatted string.

  6. Python String Formatting - W3Schools

    Before Python 3.6 we used the format() method to format strings. The format() method can still be used, but f-strings are faster and the preferred way to format strings. The next examples in this page demonstrates how to format strings with the format() method.

  7. Python String format () Method - GeeksforGeeks

    Mar 26, 2025 · format () method in Python is a tool used to create formatted strings. By embedding variables or values into placeholders within a template string, we can construct dynamic, well-organized output. It replaces the outdated % formatting method, making string interpolation more readable and efficient. Example: My name is shakshi and I am 22 years old.

  8. A Guide to Modern Python String Formatting Tools

    Feb 1, 2025 · In modern Python, you have f-strings and the .format() method to approach the tasks of interpolating and formatting strings. These tools help you embed variables and expressions directly into strings, control text alignment, and use custom format specifiers to modify how values appear.

  9. Python Print Format String: A Beginner's Guide - PyTutorial

    Feb 9, 2025 · Learn how to use Python print format strings effectively. This guide covers f-strings, format (), and %-formatting with examples for beginners.

  10. Python Print Formatting: Mastering Print Manipulation

    Print formatting is a crucial skill in Python programming, allowing developers to create dynamic, readable, and efficient text outputs. This comprehensive guide will explore the evolution of string formatting in Python, from traditional methods to modern techniques, providing you with a deep understanding of how to format strings like a pro.

  11. Some results have been removed
Refresh