Blowing in the wind(python编程实现) 给以下歌曲加上标题(Blowing in the wind) 作者(Bob Dylan) 和 尾注1962 by Warner Bros. Inc. How many roads must a man walk down Before they call him a man How many seas must a white dove sail Before she sleeps in the sand How many times must the cannon balls fly Before they're forever banned The answer my friend is blowing in the wind The answer is blowing in the wind
时间: 2023-06-10 07:04:16 浏览: 204
以下是 Python 代码实现:
```
# 加上标题
title = "Blowing in the wind"
song = "" # 存储歌曲内容
# 建立歌曲内容列表
lines = [
"How many roads must a man walk down",
"Before they call him a man",
"",
"How many seas must a white dove sail",
"Before she sleeps in the sand",
"",
"How many times must the cannon balls fly",
"Before they're forever banned",
"",
"The answer my friend is blowing in the wind",
"The answer is blowing in the wind"
]
# 将歌曲内容转化为字符串
for line in lines:
song += line + "\n"
# 加上作者和尾注
song += "\nby Bob Dylan\n1962 by Warner Bros. Inc."
# 输出完整歌曲
print(title)
print(song)
```
输出:
```
Blowing in the wind
How many roads must a man walk down
Before they call him a man
How many seas must a white dove sail
Before she sleeps in the sand
How many times must the cannon balls fly
Before they're forever banned
The answer my friend is blowing in the wind
The answer is blowing in the wind
by Bob Dylan
1962 by Warner Bros. Inc.
```
阅读全文