一、基础必备变量赋值python运行a 1 name 学习大模型打印输出python运行print(内容) print(变量)字符串拼接 / 占位python运行s f知识点{name}二、容器类型代码最常用列表 list []存多条数据python运行arr [1,2,3,文本] arr.append(内容) # 添加元素字典 dict {}存键值对接口传参、配置必用python运行data {name:张三,age:20} print(data[name]) # 取值三、判断语句python运行if 条件: 执行代码 elif 条件: 执行代码 else: 执行代码四、循环for 循环遍历文档、遍历结果最多python运行for item in 列表: print(item)五、函数定义封装工具、封装接口必用python运行def 函数名(参数): 逻辑代码 return 返回值六、导入库大模型代码 90% 都在用python运行# 固定格式 from 库名 import 组件 import 库名示例python运行from langchain.prompts import PromptTemplate七、类与对象看懂框架源码即可不用深写python运行class 类名: def __init__(self): 初始化内容 def 方法名(self): 功能八、文件操作读取文档做 RAG 高频python运行# 读取txt文件 with open(文件路径,r,encodingutf-8) as f: text f.read()九、接口请求调用大模型原生接口python运行import requests requests.post(地址,json参数)十、三大必会语法场景大模型专属传参调用组件python运行prompt PromptTemplate(input_variables[question],template模板)链式调用python运行chain.run(question问题)列表推导式文本分块常用python运行new_list [i for i in 旧列表]