1. 使用反斜杠 `\` 续行:
```python
total_sum = 100 + 200 + 300 + \
400 + 500 + 600
print(total_sum) 输出:2100
2. 使用括号 `()` 隐式换行:
```python
fruits = ['apple', 'banana', 'cherry', 'date']
print(fruits) 输出:['apple', 'banana', 'cherry', 'date']
3. 使用三引号 `"""` 或 `'''` 创建多行字符串:
```python
message = """亲爱的Python学习者:
欢迎来到代码的世界!"""
print(message) 输出:亲爱的Python学习者:
欢迎来到代码的世界!
4. 使用 `print()` 函数的 `end` 参数控制换行:
```python
print("Hello", end=" ")
print("world", end="!") 输出:Hello world!
5. 使用分号 `;` 分隔语句:
```python
a = 1; b = 2; c = 3;
print(a, b, c) 输出:1 2 3
6. 使用 `\` 在字符串中插入换行符 `\n`:
```python
A = "来看看能不能\n换行。"
print(A) 输出:来看看能不能
换行。
以上方法都可以用来在Python中实现换行。选择哪一种方法取决于你的具体需求和代码风格