Python – How to convert float to String

In Python, we can use str() to convert float to String.


pi = 3.1415

print(type(pi))  # float

piInString = str(pi)  # float -> str

print(type(piInString))  # str

Output


<class 'float'>
<class 'str'>

References

  1. Python docs – str()
  2. Python – How to convert int to String
  3. Python – How to convert String to float

About the Author

author image
mkyong
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
Matthew Recent comment authors
newest oldest most voted
Matthew
Guest
Matthew

No, it’s not working