# 转换每一行并保存到JSON文件 json_data = [convert_line_to_json(line) for line in lines if line.strip() and'¥'in line]
withopen(json_filename, 'w', encoding='utf-8') as json_file: for data in json_data: if data: # 确保数据不为None json_file.write(data + '\n') except FileNotFoundError as e: print(f"Error: {e}")