Possible Duplicate:
python limiting floats to two decimal points
i want to set 39.54484700000000 to 39.54 using python ,
how to get it ,
thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to change the actual value, use
roundas Eli suggested. However for many values and certain versions of Python this will not result be represented as the string “39.54”. If you want to just round it to produce a string to display to the user, you can door in newer versions of Python
or with the fstrings
Relevant Documentation: String Formatting Operations, Built-in Functions: round