上一页 1 2 3 4 5 6 7 8 ··· 33 下一页
摘要: import torch import numpy as np print(" tensor create: ") data = [[1, 2],[3, 4]] x_data = torch.tensor(data) print(f"x_data Tensor: \n {x_data} \n") n 阅读全文
posted @ 2025-07-24 09:28 daviyoung 阅读(7) 评论(0) 推荐(0)
摘要: ✅ Query 参数(查询参数) from fastapi import Query name: str = Query(..., title="用户名", min_length=3, max_length=50) 说明 示例 用途 从 URL 查询字符串中提取参数 示例 URL /users?na 阅读全文
posted @ 2025-07-21 17:04 daviyoung 阅读(43) 评论(0) 推荐(0)
摘要: 在 Python 中,使用 BaseModel(通常指 Pydantic 的 BaseModel)和普通的 Python class 主要区别在于数据验证、序列化和类型提示的能力。以下是它们的核心区别: 1. 普通 Python Class(不使用 BaseModel) python class P 阅读全文
posted @ 2025-07-18 17:55 daviyoung 阅读(110) 评论(0) 推荐(0)
摘要: 1、安装 pip install fastapi 2、新建main.py from fastapi import FastAPI app = FastAPI() @app.get("/") async def root(): return {"message": "Hello World"} 3、运 阅读全文
posted @ 2025-07-18 17:31 daviyoung 阅读(10) 评论(0) 推荐(0)
摘要: vs code中: 创建虚拟环境 python -m venv .venv 激活: .\.venv\Scripts\activate 激活虚拟环境后即可使用。 删除虚拟环境 # 先退出虚拟环境(如果已激活) deactivate # 删除虚拟环境目录 Remove-Item -Recurse -Fo 阅读全文
posted @ 2025-07-18 17:24 daviyoung 阅读(12) 评论(0) 推荐(0)
摘要: FastAPI 的路由系统是其核心组件之一,负责将客户端请求(如 HTTP GET、POST 等)映射到具体的处理函数(也叫“视图函数”或“端点”)。下面是 FastAPI 路由相关的知识总结,涵盖基本使用、进阶功能、最佳实践等。 🧱 基础知识 1. 路由定义方式 from fastapi imp 阅读全文
posted @ 2025-07-18 17:09 daviyoung 阅读(101) 评论(0) 推荐(0)
摘要: 服务端: 客户端: 参考文章:OPCServer:使用Matrikon OPC Server Simulation_matrikonopcsimulation安装失败-CSDN博客 阅读全文
posted @ 2025-07-11 11:10 daviyoung 阅读(152) 评论(0) 推荐(0)
摘要: 一、Nuget上添加OpcUaHelper库,要使用最新的版本2.2.1,旧版本亲测无法连接,比如版本2.1.3经过测试无法连接 二、代码 class Program { static async Task Main(string[] args) { OpcUaClient opcUaClient 阅读全文
posted @ 2025-07-08 15:47 daviyoung 阅读(572) 评论(0) 推荐(0)
摘要: 一、需要确认opc服务器的节点类型是数字型还是字符串型。 例如:数字型:i=2 字符串型:s=Temperature 假如命名空间索引是2,那么ns=2 采集数字型: node_address = "ns=2;i=2" 采集字符串型: node_address = "ns=2;s=Temperatu 阅读全文
posted @ 2025-07-08 10:24 daviyoung 阅读(285) 评论(0) 推荐(0)
摘要: 一、安装库opcua pip install opcua 二、新建文件opcua_server.py # -*- coding: utf-8 -*- from opcua import Client import time # 配置客户端 server_url = "opc.tcp://localh 阅读全文
posted @ 2025-07-08 10:21 daviyoung 阅读(268) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 ··· 33 下一页