{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c25df30f-58cb-4969-869a-127bcf5be598",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-05-14T11:55:32.361511Z",
     "iopub.status.busy": "2026-05-14T11:55:32.361336Z",
     "iopub.status.idle": "2026-05-14T11:55:33.172943Z",
     "shell.execute_reply": "2026-05-14T11:55:33.172258Z",
     "shell.execute_reply.started": "2026-05-14T11:55:32.361494Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "csv模块读取结果：\n",
      "['Name', 'Age', 'City']\n",
      "['Alice', '25', 'New York']\n",
      "['Bob', '30', 'London']\n",
      "\n",
      "pandas读取结果：\n",
      "    Name  Age      City\n",
      "0  Alice   25  New York\n",
      "1    Bob   30    London\n",
      "平均年龄: 27.5\n"
     ]
    }
   ],
   "source": [
    "# 依赖库：csv（内置）、pandas（需安装）\n",
    "# pip install pandas\n",
    "\n",
    "import csv\n",
    "import pandas as pd\n",
    "\n",
    "# ------------------ 创建并保存CSV文件 ------------------\n",
    "# 使用 csv 模块创建\n",
    "with open('demo.csv', 'w', newline='', encoding='utf-8') as f:\n",
    "    writer = csv.writer(f)\n",
    "    writer.writerow([\"Name\", \"Age\", \"City\"])   # 标题行\n",
    "    writer.writerow([\"Alice\", 25, \"New York\"])  # 数据行\n",
    "    writer.writerow([\"Bob\", 30, \"London\"])\n",
    "\n",
    "# ------------------ 读取并操作CSV文件 ------------------\n",
    "# 使用 csv 模块读取\n",
    "with open('demo.csv', 'r', encoding='utf-8') as f:\n",
    "    reader = csv.reader(f)\n",
    "    print(\"csv模块读取结果：\")\n",
    "    for row in reader:\n",
    "        print(row)\n",
    "\n",
    "# 使用 pandas 读取\n",
    "df = pd.read_csv('demo.csv')\n",
    "print(\"\\npandas读取结果：\")\n",
    "print(df)\n",
    "print(\"平均年龄:\", df['Age'].mean())  # 计算平均年龄"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "28ea5a3d-6e8b-4f55-8b7b-b9405d9565fd",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-05-14T11:55:34.702728Z",
     "iopub.status.busy": "2026-05-14T11:55:34.702526Z",
     "iopub.status.idle": "2026-05-14T11:55:35.008568Z",
     "shell.execute_reply": "2026-05-14T11:55:35.007964Z",
     "shell.execute_reply.started": "2026-05-14T11:55:34.702710Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Excel数据：\n",
      "    Name  Age      City\n",
      "0  Alice   25  New York\n",
      "1    Bob   30    London\n",
      "最大年龄: 30\n",
      "\n",
      "单元格A2的值: Alice\n"
     ]
    }
   ],
   "source": [
    "# 依赖库：openpyxl、pandas\n",
    "# pip install openpyxl pandas\n",
    "\n",
    "import pandas as pd\n",
    "from openpyxl import Workbook\n",
    "\n",
    "# ------------------ 创建并保存Excel文件 ------------------\n",
    "# 使用 openpyxl 创建\n",
    "wb = Workbook()\n",
    "ws = wb.active\n",
    "ws.title = \"Users\"\n",
    "ws.append([\"Name\", \"Age\", \"City\"])  # 标题行\n",
    "ws.append([\"Alice\", 25, \"New York\"])\n",
    "ws.append([\"Bob\", 30, \"London\"])\n",
    "wb.save('demo.xlsx')\n",
    "\n",
    "# ------------------ 读取并操作Excel文件 ------------------\n",
    "# 使用 pandas 读取\n",
    "df = pd.read_excel('demo.xlsx', sheet_name='Users')\n",
    "print(\"Excel数据：\")\n",
    "print(df)\n",
    "print(\"最大年龄:\", df['Age'].max())  # 计算最大年龄\n",
    "\n",
    "# 使用 openpyxl 读取单元格\n",
    "from openpyxl import load_workbook\n",
    "wb = load_workbook('demo.xlsx')\n",
    "sheet = wb['Users']\n",
    "print(\"\\n单元格A2的值:\", sheet['A2'].value)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "02f6c979-56b7-4422-833d-4b3494902296",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-05-14T11:55:38.700025Z",
     "iopub.status.busy": "2026-05-14T11:55:38.699758Z",
     "iopub.status.idle": "2026-05-14T11:55:42.814890Z",
     "shell.execute_reply": "2026-05-14T11:55:42.814332Z",
     "shell.execute_reply.started": "2026-05-14T11:55:38.700003Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Looking in indexes: https://mirrors.cloud.aliyuncs.com/pypi/simple\n",
      "Collecting PyPDF2\n",
      "  Downloading https://mirrors.cloud.aliyuncs.com/pypi/packages/8e/5e/c86a5643653825d3c913719e788e41386bee415c2b87b4f955432f2de6b2/pypdf2-3.0.1-py3-none-any.whl (232 kB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m232.6/232.6 kB\u001b[0m \u001b[31m14.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hCollecting reportlab\n",
      "  Downloading https://mirrors.cloud.aliyuncs.com/pypi/packages/a7/45/ea7fad10122440de6e845568d106bffdc456ca0e8a1d8ae10b46016087e4/reportlab-4.5.1-py3-none-any.whl (2.0 MB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.0/2.0 MB\u001b[0m \u001b[31m29.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n",
      "\u001b[?25hRequirement already satisfied: pillow>=9.0.0 in /usr/local/lib/python3.11/site-packages (from reportlab) (11.3.0)\n",
      "Requirement already satisfied: charset-normalizer in /usr/local/lib/python3.11/site-packages (from reportlab) (3.4.5)\n",
      "Installing collected packages: reportlab, PyPDF2\n",
      "Successfully installed PyPDF2-3.0.1 reportlab-4.5.1\n",
      "\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\u001b[33m\n",
      "\u001b[0m\n",
      "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.3.2\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m26.1.1\u001b[0m\n",
      "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n"
     ]
    }
   ],
   "source": [
    "!pip install PyPDF2 reportlab"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "3fd191fd-e696-4473-be7f-f3d5f459d0db",
   "metadata": {
    "ExecutionIndicator": {
     "show": false
    },
    "execution": {
     "iopub.execute_input": "2026-05-14T11:55:42.815669Z",
     "iopub.status.busy": "2026-05-14T11:55:42.815517Z",
     "iopub.status.idle": "2026-05-14T11:55:42.992098Z",
     "shell.execute_reply": "2026-05-14T11:55:42.991569Z",
     "shell.execute_reply.started": "2026-05-14T11:55:42.815651Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "PDF内容:\n",
      " PDF■■■■\n",
      "■■: Alice\n",
      "■■: 25\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# 依赖库：PyPDF2（创建PDF需要ReportLab）\n",
    "# pip install PyPDF2 reportlab\n",
    "\n",
    "from PyPDF2 import PdfWriter, PdfReader\n",
    "from reportlab.pdfgen import canvas\n",
    "import io\n",
    "\n",
    "# ------------------ 创建并保存PDF文件 ------------------\n",
    "# 使用 ReportLab 生成PDF内容\n",
    "packet = io.BytesIO()\n",
    "c = canvas.Canvas(packet)\n",
    "c.drawString(50, 800, \"PDF示例文档\")  # 添加文本\n",
    "c.drawString(50, 780, \"姓名: Alice\")\n",
    "c.drawString(50, 760, \"年龄: 25\")\n",
    "c.save()\n",
    "\n",
    "# 保存为本地文件\n",
    "packet.seek(0)\n",
    "new_pdf = PdfReader(packet)\n",
    "writer = PdfWriter()\n",
    "writer.add_page(new_pdf.pages[0])\n",
    "with open(\"demo.pdf\", \"wb\") as f:\n",
    "    writer.write(f)\n",
    "\n",
    "# ------------------ 读取并提取PDF文本 ------------------\n",
    "with open(\"demo.pdf\", \"rb\") as f:\n",
    "    reader = PdfReader(f)\n",
    "    page = reader.pages[0]\n",
    "    text = page.extract_text()\n",
    "    print(\"PDF内容:\\n\", text)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "f19a18ac-9d64-4136-8694-c035ac889e4e",
   "metadata": {
    "ExecutionIndicator": {
     "show": true
    },
    "execution": {
     "iopub.execute_input": "2026-05-14T11:55:45.091105Z",
     "iopub.status.busy": "2026-05-14T11:55:45.090930Z",
     "iopub.status.idle": "2026-05-14T11:55:45.113172Z",
     "shell.execute_reply": "2026-05-14T11:55:45.112538Z",
     "shell.execute_reply.started": "2026-05-14T11:55:45.091088Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "PDF内容:\n",
      " 212.浆母细胞淋巴瘤。\n",
      "13.原发渗出性淋巴瘤。\n",
      "14.疱疹病毒8阳性弥漫大B细胞淋巴瘤，非特指型。\n",
      "15.伯基特淋巴瘤\n",
      "16.伴有11q异常的伯基特样淋巴瘤\n",
      "17.高级别B细胞淋巴瘤，伴有MYC和BCL2和/或BCL6重排。\n",
      "18.高级别B细胞淋巴瘤，非特指型。\n",
      "19.B细胞淋巴瘤不能分类型，介于DLBCL和经典霍奇金淋巴\n",
      "瘤之间。\n",
      "由于各亚型的预后及诊疗存在差异，本文将以弥漫大B细胞淋\n",
      "巴瘤，非特指型为主讨论诊疗指南。\n",
      "二、诊断及鉴别诊断\n",
      "（一）临床表现。\n",
      "1.症状。\n",
      "淋巴结（累及淋巴结）或结外（累及淋巴系统外的器官或组织）\n",
      "症状：任何淋巴结外部位都可能累及。患者通常出现进行性肿大的\n",
      "无痛性肿物，多见于颈部或腹部。累及淋巴结外者根据累及部位不\n",
      "同出现相应症状，常见的有：胃肠道、中枢神经系统、骨骼。也可\n",
      "以在肝脏、肺、肾脏或膀胱等罕见部位发生。可以出现疾病或治疗\n",
      "相关的肿瘤溶解综合征，即肿瘤细胞内容物自发释放或由于化疗反\n",
      "应而释放到血液中，引起电解质和代谢失衡，伴有进行性系统性毒\n"
     ]
    }
   ],
   "source": [
    "with open(\"弥漫性大B细胞淋巴瘤诊疗指南+（2022年版）.pdf\", \"rb\") as f:\n",
    "    reader = PdfReader(f)\n",
    "    page = reader.pages[1]\n",
    "    text = page.extract_text()\n",
    "    print(\"PDF内容:\\n\", text)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "ffa46f7f-f045-4dba-8c21-401793d6e256",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-05-14T11:55:47.451241Z",
     "iopub.status.busy": "2026-05-14T11:55:47.451079Z",
     "iopub.status.idle": "2026-05-14T11:55:50.566175Z",
     "shell.execute_reply": "2026-05-14T11:55:50.565558Z",
     "shell.execute_reply.started": "2026-05-14T11:55:47.451225Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Looking in indexes: https://mirrors.cloud.aliyuncs.com/pypi/simple\n",
      "Collecting python-docx\n",
      "  Downloading https://mirrors.cloud.aliyuncs.com/pypi/packages/d0/00/1e03a4989fa5795da308cd774f05b704ace555a70f9bf9d3be057b680bcf/python_docx-1.2.0-py3-none-any.whl (252 kB)\n",
      "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m253.0/253.0 kB\u001b[0m \u001b[31m9.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
      "\u001b[?25hRequirement already satisfied: lxml>=3.1.0 in /usr/local/lib/python3.11/site-packages (from python-docx) (6.0.2)\n",
      "Requirement already satisfied: typing_extensions>=4.9.0 in /usr/local/lib/python3.11/site-packages (from python-docx) (4.15.0)\n",
      "Installing collected packages: python-docx\n",
      "Successfully installed python-docx-1.2.0\n",
      "\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\u001b[33m\n",
      "\u001b[0m\n",
      "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.3.2\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m26.1.1\u001b[0m\n",
      "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n"
     ]
    }
   ],
   "source": [
    "!pip install python-docx"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "507face7-dca2-4b25-b878-2d934518ae92",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-05-14T11:55:52.071645Z",
     "iopub.status.busy": "2026-05-14T11:55:52.071452Z",
     "iopub.status.idle": "2026-05-14T11:55:52.223743Z",
     "shell.execute_reply": "2026-05-14T11:55:52.223209Z",
     "shell.execute_reply.started": "2026-05-14T11:55:52.071626Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Word内容:\n",
      "用户信息\n",
      "姓名: Alice\n",
      "年龄: 25\n",
      "城市: New York\n",
      "\n",
      "表格内容:\n",
      "['姓名', '年龄', '城市']\n",
      "['Bob', '30', 'London']\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/usr/local/lib/python3.11/site-packages/docx/styles/styles.py:125: UserWarning: style lookup by style_id is deprecated. Use style name as key instead.\n",
      "  return self._get_style_id_from_style(self[style_name], style_type)\n"
     ]
    }
   ],
   "source": [
    "# 依赖库：python-docx\n",
    "# pip install python-docx\n",
    "\n",
    "from docx import Document\n",
    "\n",
    "# ------------------ 创建并保存Word文件 ------------------\n",
    "doc = Document()\n",
    "doc.add_heading(\"用户信息\", level=1)  # 添加标题\n",
    "doc.add_paragraph(\"姓名: Alice\")     # 添加段落\n",
    "doc.add_paragraph(\"年龄: 25\")\n",
    "doc.add_paragraph(\"城市: New York\")\n",
    "\n",
    "# 添加表格\n",
    "table = doc.add_table(rows=1, cols=3)\n",
    "table.style = \"LightShading-Accent1\"\n",
    "headers = table.rows[0].cells\n",
    "headers[0].text = \"姓名\"\n",
    "headers[1].text = \"年龄\"\n",
    "headers[2].text = \"城市\"\n",
    "row = table.add_row().cells\n",
    "row[0].text = \"Bob\"\n",
    "row[1].text = \"30\"\n",
    "row[2].text = \"London\"\n",
    "doc.save(\"demo.docx\")\n",
    "\n",
    "# ------------------ 读取并操作Word文件 ------------------\n",
    "doc = Document(\"demo.docx\")\n",
    "print(\"Word内容:\")\n",
    "for para in doc.paragraphs:\n",
    "    print(para.text)\n",
    "\n",
    "print(\"\\n表格内容:\")\n",
    "for table in doc.tables:\n",
    "    for row in table.rows:\n",
    "        cells = [cell.text for cell in row.cells]\n",
    "        print(cells)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "81a57df4-8483-438c-aa09-b7e2391b654e",
   "metadata": {
    "ExecutionIndicator": {
     "show": true
    },
    "execution": {
     "iopub.execute_input": "2026-05-14T11:56:22.592000Z",
     "iopub.status.busy": "2026-05-14T11:56:22.591823Z",
     "iopub.status.idle": "2026-05-14T11:56:22.616357Z",
     "shell.execute_reply": "2026-05-14T11:56:22.615722Z",
     "shell.execute_reply.started": "2026-05-14T11:56:22.591984Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Word内容:\n",
      "“大语言模型与智能体在医学领域的应用”培训班安排\n",
      "\n",
      "\n",
      "\n",
      "表格内容:\n",
      "['日期', '时间', '讲授题目', '授课老师']\n",
      "['第一天', '9:00-10:00', '人工智能与大语言模型简介\\n-人工智能发展简史\\n-大语言模型的基本概念与分类 \\n-大语言模型在医学领域的潜力', '朱政 副教授']\n",
      "['第一天', '10:00-11:00', '大语言模型的工作原理\\n-语言模型的基本架构（Transformer）\\n-提示工程、检索增强生成、微调的概念\\n-模型如何生成文本', '朱政 副教授']\n",
      "['第一天', '11:00-11:30', '大语言模型的常见应用场景案例\\n-文本生成和问答系统\\n-诊断和预测\\n-智能体与自动化任务', '朱政 副教授']\n",
      "['第一天', '13:30-14:30', '大语言模型工具入门\\n-常用大语言模型工具介绍（如ChatGPT、Claude等）\\n-网页端问答工具的使用与实操', '']\n",
      "['第一天', '14:30-17:00', 'Python与大语言模型API入门\\n-Python环境配置与基础语法\\n-调用大语言模型API的基本方法\\n-实操：使用Python调用API生成文本', '']\n",
      "['第二天', '9:00-10:00', '提示词工程基础\\n-提示词的作用与设计原则\\n-常见提示词类型（指令式、开放式等）\\n-实操：设计提示词生成医学文本', '']\n",
      "['第二天', '10:00-11:30', '高级提示词技巧\\n-少样本提示\\n-思维链\\n-实操：使用思维链解决复杂医学问题', '']\n",
      "['第二天', '13:30-15:00', 'RAG（检索增强生成）基础\\n-RAG的基本原理与架构\\n-RAG在医学领域的应用场景\\n-实操：使用RAG进行医学文献检索与生成', '']\n",
      "['第二天', '15:00-17:00', 'RAG与知识图谱的结合应用\\n- 知识图谱的基本概念与构建方法\\n- 知识图谱在医学领域的应用\\n- 实操：结合RAG与知识图谱进行医学问答', '']\n",
      "['第三天', '9:00-10:00', '大语言模型微调基础\\n-什么是模型微调\\n-微调的常见方法（全参数微调、LoRA等）\\n-医学数据集的准备与处理', '']\n",
      "['', '10:00-11:30', '实操：基于医学数据的微调\\n-使用开源工具（如Hugging Face）进行微调\\n-实操：微调一个简单的医学问答模型', '']\n",
      "['', '13:30-15:00', '智能体基础\\n-什么是智能体（Agent）\\n-智能体的基本架构与工作原理\\n-智能体在医学领域的应用场景', '朱政 副教授']\n",
      "['', '15:00-17:00', '实操：构建医学问答智能体\\n-使用低代码平台构建智能体\\n-实操：设计一个简单的医学问答系统', '']\n"
     ]
    }
   ],
   "source": [
    "doc = Document(\"./大语言模型与智能体在医学领域的应用-v3.docx\")\n",
    "print(\"Word内容:\")\n",
    "for para in doc.paragraphs:\n",
    "    print(para.text)\n",
    "\n",
    "print(\"\\n表格内容:\")\n",
    "for table in doc.tables:\n",
    "    for row in table.rows:\n",
    "        cells = [cell.text for cell in row.cells]\n",
    "        print(cells)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "3520dd06-fed2-4259-81a3-160326d0f4f8",
   "metadata": {
    "ExecutionIndicator": {
     "show": false
    },
    "execution": {
     "iopub.execute_input": "2026-05-14T11:56:52.753679Z",
     "iopub.status.busy": "2026-05-14T11:56:52.753503Z",
     "iopub.status.idle": "2026-05-14T11:56:52.758613Z",
     "shell.execute_reply": "2026-05-14T11:56:52.758179Z",
     "shell.execute_reply.started": "2026-05-14T11:56:52.753662Z"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'nodes': [{'name': '弥漫性大B细胞淋巴瘤', 'type': '疾病', 'description': '来源于成熟B细胞的侵袭性肿瘤'}, {'name': '非特指型', 'type': '亚型', 'description': 'DLBCL的亚型之一'}, {'name': '无痛性肿物', 'type': '症状', 'description': '常见症状之一'}, {'name': '病理活检', 'type': '诊断方法', 'description': '确诊DLBCL的主要方法'}, {'name': 'R-CHOP', 'type': '治疗方案', 'description': '一线治疗方案'}, {'name': 'IPI', 'type': '预后因素', 'description': '国际预后指数'}, {'name': '年龄＞60岁', 'type': '危险因素', 'description': 'IPI危险因素之一'}, {'name': '三联鞘内注射', 'type': '预防方法', 'description': '中枢神经系统预防方法'}, {'name': '3个月一次随访', 'type': '随访建议', 'description': '治疗后随访频率'}], 'relationships': [{'source': '弥漫性大B细胞淋巴瘤', 'target': '非特指型', 'type': 'HAS_SUBTYPE'}, {'source': '弥漫性大B细胞淋巴瘤', 'target': '无痛性肿物', 'type': 'HAS_SYMPTOM'}, {'source': '弥漫性大B细胞淋巴瘤', 'target': '病理活检', 'type': 'DIAGNOSED_BY'}, {'source': '弥漫性大B细胞淋巴瘤', 'target': 'R-CHOP', 'type': 'TREATED_WITH'}, {'source': '弥漫性大B细胞淋巴瘤', 'target': 'IPI', 'type': 'HAS_PROGNOSTIC_FACTOR'}, {'source': '弥漫性大B细胞淋巴瘤', 'target': '年龄＞60岁', 'type': 'HAS_RISK_FACTOR'}, {'source': '弥漫性大B细胞淋巴瘤', 'target': '三联鞘内注射', 'type': 'PREVENTED_BY'}, {'source': '弥漫性大B细胞淋巴瘤', 'target': '3个月一次随访', 'type': 'FOLLOWED_BY'}]}\n",
      "[{'name': '弥漫性大B细胞淋巴瘤', 'type': '疾病', 'description': '来源于成熟B细胞的侵袭性肿瘤'}, {'name': '非特指型', 'type': '亚型', 'description': 'DLBCL的亚型之一'}, {'name': '无痛性肿物', 'type': '症状', 'description': '常见症状之一'}, {'name': '病理活检', 'type': '诊断方法', 'description': '确诊DLBCL的主要方法'}, {'name': 'R-CHOP', 'type': '治疗方案', 'description': '一线治疗方案'}, {'name': 'IPI', 'type': '预后因素', 'description': '国际预后指数'}, {'name': '年龄＞60岁', 'type': '危险因素', 'description': 'IPI危险因素之一'}, {'name': '三联鞘内注射', 'type': '预防方法', 'description': '中枢神经系统预防方法'}, {'name': '3个月一次随访', 'type': '随访建议', 'description': '治疗后随访频率'}]\n"
     ]
    }
   ],
   "source": [
    "import json\n",
    "\n",
    "# 读取JSON文件\n",
    "with open('./dlbcl_knowledge_graph.json', 'r', encoding='utf-8') as file:\n",
    "    data = json.load(file)\n",
    "    print(data)  # 打印JSON数据\n",
    "\n",
    "# 访问JSON数据中的特定字段\n",
    "print(data['nodes'])  # 假设JSON数据中有'nodes'字段"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
