From 591d9783dc2aba1ea8e1bde29f2afdd017ee1439 Mon Sep 17 00:00:00 2001 From: Jason Wu Date: Thu, 15 Oct 2020 22:24:58 +0800 Subject: [PATCH] Fix code block without python suffixed --- zh_CN/3-tips-on-numbers-and-strings.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zh_CN/3-tips-on-numbers-and-strings.md b/zh_CN/3-tips-on-numbers-and-strings.md index 593080a..2061a7d 100644 --- a/zh_CN/3-tips-on-numbers-and-strings.md +++ b/zh_CN/3-tips-on-numbers-and-strings.md @@ -262,7 +262,7 @@ def main(): 但是这样写会破坏整段代码的缩进视觉效果,显得非常突兀。要改善它有很多种办法,比如我们可以把这段多行字符串作为变量提取到模块的最外层。不过,如果在你的代码逻辑里更适合用字面量的话,你也可以用标准库 `textwrap` 来解决这个问题: -``` +```python from textwrap import dedent def main(): @@ -284,7 +284,7 @@ def main(): 比如: -``` +```python >>> 10_000_000.0 # 以“千”为单位划分数字 10000000.0 >>> 0xCAFE_F00D # 16进制数字同样有效,4个一组更易读 @@ -357,7 +357,7 @@ Python 的字符串有着非常多实用的内建方法,最常用的有 `.stri 我们可以用前面提到的 `dis` 模块来验证一下: -``` +```python def incr(value): value += 1