1. 使用单引号(`'`):
```python
string1 = 'Hello, World!'
2. 使用双引号(`"`):
```python
string2 = "Hello, World!"
3. 使用三引号(`'''` 或 `"""`):
```python
string3 = """This is a multi-line string.
It covers multiple lines."""
4. 使用转义字符(`\`):
```python
string4 = 'This is a string with a "quote": \'Hello, World!\'
5. 字符串格式化:
```python
name = "John"
age = 30
print("My name is %s and I am %d years old." % (name, age))
6. 字符串连接:
```python
new_string = string1 + "!"
7. 字符串切片:
```python
print(string1[0:5]) 输出 "Hello"
8. 字符串比较:
```python
print(string1 == string2) 输出 True
以上是Python中定义字符串的基本方法。您可以根据需要选择使用单引号、双引号或三引号,并且可以利用字符串的切片、连接、格式化等功能来处理字符串