Advertisement



< Prev
Next >



Python - String Formattting




String formatting allows us to format a string value before it is sent as an output to the user. In this tutorial, we are going to discuss an important string formatting method, format(). But before we could discuss how to format a string value, we should learn about how to extract a string representation of an object.

Therefore, first we are going to discuss some two important functions, str() and repr(), which allow us to retrieve a string representation of any object.

Next, we are going to discuss the string formatting method, format() and its variations provided by the Python.


Functions/Method Description
str()
This function formats an object passed to it and returns its human-readable form.

repr()
This function returns an interpreter-readable form of an object passed to it.

format()
This method returns a formatted string value and it is used to format specified value(s) passed to it and insert them inside the string's placeholder. This method is only available to string objects.






Please Subscribe

Please subscribe to our social media channels for daily updates.


Decodejava Facebook Page  DecodeJava Twitter Page Decodejava Google+ Page




Advertisement



Notifications



Please check our latest addition

C#, PYTHON and DJANGO


Advertisement