20.6. 列表-代码块

以下3种效果相同:

一. 不缩进,无空行

- list1
```python
text1 = "Hello, "
text2 = "world!"
print text1 + text2
```

二. 缩进,无空行

- list1
    ```python
    text1 = "Hello, "
    text2 = "world!"
    print text1 + text2
    ```

三. 缩进,有空行

- list1

    ```python
    text1 = "Hello, "
    text2 = "world!"
    print text1 + text2
    ```

效果均如下

  • list1

    text1 = "Hello, "
    text2 = "world!"
    print text1 + text2
    

注意: 不能无缩进却有空行,如下面这样是有问题的,可以自行测试:

- list1

```python
text1 = "Hello, "
text2 = "world!"
print text1 + text2
```