Skip to content

Commit

Permalink
fixed the display problem in Pandas
Browse files Browse the repository at this point in the history
  • Loading branch information
Promesis committed Feb 17, 2024
1 parent 8ebba12 commit 6749cc8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions _posts/python/2024-2-15-Pandas.md
Original file line number Diff line number Diff line change
Expand Up @@ -472,16 +472,22 @@ print(f'{"carol" :>10} {16 :>10} {37.315 :>10.2f}')

f-string的格式说明符非常简洁,使用`>`向右对齐,使用`<`向左对齐,使用`^`向中间对齐。在对齐要求后面加上类似于`%`格式字符串的控制说明符也可以作同样的精度控制操作。

如果要在f-string中输出`}``{`字符需要使用两个花括号,如`}}` `{{`,否则会引起歧义而报错。输出引号(单引号、双引号)也需要适当的转义,否则也报错。观察:
如果要在f-string中输出`}``{`字符需要使用两个花括号,如`}}`
`{{`
,否则会引起歧义而报错。输出引号(单引号、双引号)也需要适当的转义,否则也报错。观察:


```python
print(f"print(f\"{{x}} + {{y}} = {{x + y}}\") produces:\n{x} + {y} = {x + y}")
```

print(f"{x} + {y} = {x + y}") produces:
1 + 2 = 3


```
print(f"{x} + {y} = {x + y}") produces:
1 + 2 = 3
```



# **Pandas**

Expand Down

0 comments on commit 6749cc8

Please sign in to comment.