开始使用免费开始使用

多行字符串

您的食谱缩放项目需要为每道菜保存详细的烹饪说明。这些说明通常跨越多行,并包含多个步骤。您将练习存储一个包含意面完整烹饪步骤的多行字符串,便于在代码中阅读和维护。

本练习是课程的一部分

Python for Developers 入门

查看课程

练习说明

  • 创建一个名为 cooking_instructions 的多行字符串变量,其中包含注释中展示的三步意面烹饪流程。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Store the multi-line cooking instructions
# Step 1: Boil water in a large pot
# Step 2: Add pasta and cook for 10 minutes
# Step 3: Drain and serve with sauce
cooking_instructions = ____

print(cooking_instructions)
编辑并运行代码