以下是用 Python 实现的代码: ```python import os def count_question_types_and_numbers(folder_path): question_types = {} file_path = os.path.join(folder_path, 'python 题库(考试用)') with open(file_path, 'r') as file: lines = file.readlines() for line in lines: # 去除每行前后的空格和换行符 line = line.strip() if line.startswith('(1)'): # 识别为选择题 if '选择题' in question_types: question_types['选择题'] += 1 else: question_types['选择题'] = 1 for key, value in question_types.items(): print(f"{key}: {value}") folder_path = 'your_folder_path' # 请将这里替换为实际的文件夹路径 count_question_types_and_numbers(folder_path) ``` 额外需要注意的逻辑点: 1. 确保文件夹路径的正确性,否则无法读取到题库文件。 2. 处理文件内容时,要考虑可能存在的格式不一致或异常情况。 3. 统计类型时,要准确判断题目的类型特征,避免误判。 [2024-12-11 13:37:02 | AI写代码神器 | 276点数解答]