How to convert float to string with 2 decimal places in Python

2 Answers

0 votes
f = 787324.9761

s = "{:.2f}".format(f)

print(f)



'''
run:

787324.9761

'''

 



answered Feb 13, 2023 by avibootz
0 votes
float_number = 787324.9761

s = f'{float_number:.2f}'

print(float_number)



'''
run:

787324.9761

'''

 



answered Feb 13, 2023 by avibootz

Related questions

1 answer 260 views
4 answers 746 views
1 answer 310 views
2 answers 368 views
2 answers 408 views
1 answer 306 views
...