""" Author:Zhou Create_Date:2022年06月08日--23:20 Tool:PyCharm Software: PyCharm """ """ 使用函数结合while+字典返回值 """ def make_album(singer_name, album_name, song_number=None): album = { 'singer_name': singer_name, '
Author:Zhou
Create_Date:2022年06月08日--23:20
Tool:PyCharm
Software: PyCharm
"""
"""
使用函数结合while+字典返回值
"""
def make_album(singer_name, album_name, song_number=None):
album = {
'singer_name': singer_name,
'album_name': album_name
}
# 如果歌曲数目为0
if song_number:
album['song_number'] = song_number
return album
else:
return album
choose = input('是否输入专辑信息(y/n)?')
while choose == 'y':
singer_name = input('请输入歌手名:')
album_name = input('请输入专辑名称:')
song_number = input('请输入专辑中歌曲数量:')
album = make_album(singer_name, album_name, song_number)
print(album)
choose = input('是否输入专辑信息(y/n)?')
print('已退出,欢迎使用!')