Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

格式化一个浮点数,保留小数点后两位 #17

Open
Sogrey opened this issue Feb 14, 2020 · 0 comments
Open

格式化一个浮点数,保留小数点后两位 #17

Sogrey opened this issue Feb 14, 2020 · 0 comments

Comments

@Sogrey
Copy link
Owner

Sogrey commented Feb 14, 2020

x1 = 1234.56789
x2 = 30.1
print(format(x1, '0.2f'))  # 保留小数点后两位  ##  1234.57
print(format(x2,'0.2f'))  ## 30.10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant