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