python3拼接符
2024-02-15 17:10:32
```python
ship_description = 'This is our beautiful ship, the ' + ship_name + '.'
```
```python
ship_description = f'This is our beautiful ship, the {ship_name}.'
```
```python
price =
duration =
description = f'You can rent our ship for ${price} per hour, for a minimum of {duration} hours.'
```
這種方式讓我司直接在字符串中嵌入變量,使得代碼更易于理解和維護(hù)。
"The package has been delivered to {street}, {city}, {state}."。
"Dear {parent_name}, your child {child_name} has completed lesson {lesson_number}."。
"The water level at reservoir {reservoir_id} is currently {water_level} meters."。