Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

question related to formatting . Usage of format() in python

could anyone explain how format() works in python? where to use it, and how to use it?. I am not getting even I about this keyword

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You can regarding it as a kind of string replacement.

{} part in the string -> string.format() content

Definition: https://www.w3schools.com/python/ref_string_format.asp

A pratical example can be like this:

base_url = 'www.xxxx.com/test?page={}'
for i in range(10):
    url = base_url.format(i)
    do sth
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading