在Python中,定义字符串可以使用以下几种方式包裹:
1. 单引号(`'`):
```python
s1 = 'I am Tom'
2. 双引号(`"`):
```python
s2 = "I am Tom"
3. 三引号(`'''` 或 `"""`):
```python
s3 = """I am Tom
This is a multi-line string.
It can contain any characters, including Chinese."""
当字符串中包含引号时,可以使用转义字符(`\`)来避免冲突,例如:
```python
s4 = 'He said, "Hello!"'
Python 3默认支持Unicode字符串,可以直接使用引号包裹汉字文本。