pythonV1V2/第32讲自动组卷系统(一)/课堂成果/课后作业-小明最喜欢的动漫.py
sairate 7df250638d chore: 添加项目基础结构和示例代码
- 创建 .idea 目录和相关配置文件,设置项目结构
- 添加多个课堂成果示例代码,涵盖不同主题和功能
- 创建和配置 .gitignore 文件,忽略特定文件和目录
2025-07-05 09:36:00 +08:00

12 lines
606 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'''写一个小程序,帮助小明记录他最喜欢的动漫和对它们的描述。程序会先询问小明最喜欢的动漫数量,然后依次让小明输入每个动漫的名称和描述。最后,程序会将记录保存到一个文件中。文件示意如下。'''
my_file = open('小明最喜欢的动漫', 'w')
my_file.write(' '*20 + '小明最喜欢的动漫\n')
num = int(input('小明最喜欢的动漫数量:'))
for i in range(num):
name = input('动漫名称:')
story = input('动漫描述:')
my_file.write(f'{name}{story}')
my_file.write('\n')
my_file.close()