f=1.23444432 print("Converted f to String:",str(f))
Let’s say you want to format String to only two decimal places.
You can use below code to do it.
f=1.23444432 #Use 5 characters, give 2 decimal places s = "%5.2f" % f print("Converted f to String:",s)
That’s all about converting float to String in python.
The post Python Float to String appeared first on Java2Blog.