fix
This commit is contained in:
@@ -38,7 +38,7 @@ print(".2f" % a/b) # 这里是错误的❌
|
|||||||
a=10
|
a=10
|
||||||
b=3
|
b=3
|
||||||
c=a/b
|
c=a/b
|
||||||
print(".2f" % c) # 这样是正确的✔
|
print("%.2f" % c) # 这样是正确的✔
|
||||||
```
|
```
|
||||||
|
|
||||||
或者,把计算表达式用括号包起来
|
或者,把计算表达式用括号包起来
|
||||||
@@ -46,7 +46,7 @@ print(".2f" % c) # 这样是正确的✔
|
|||||||
```py
|
```py
|
||||||
a=10
|
a=10
|
||||||
b=3
|
b=3
|
||||||
print(".2f" % (a/b)) # 这样是正确的✔
|
print("%.2f" % (a/b)) # 这样是正确的✔
|
||||||
```
|
```
|
||||||
|
|
||||||
## format() 函数
|
## format() 函数
|
||||||
|
|||||||
Reference in New Issue
Block a user