随笔分类 -  python

摘要:Python requests 库使用 1. 基本用法 1.1 发送 GET 请求 import requests response = requests.get('https://example.com') print(response.status_code) # HTTP 状态码 print( 阅读全文
posted @ 2024-10-14 14:31 ganph 阅读(111) 评论(0) 推荐(0)
摘要:Python 装饰器 1. 装饰器是什么 装饰器是 Python 中的一种高级函数,用于在不修改原始函数代码的前提下,动态地为函数或类增加功能。它本质上是一个函数,接受另一个函数或类作为参数,并返回一个新的函数或类。 装饰器的基本语法 def decorator(func): def wrapper 阅读全文
posted @ 2024-10-11 15:08 ganph 阅读(315) 评论(0) 推荐(0)
摘要:import time import serial def test_receive(): # 配置串口参数 port = '/dev/ttyUSB0' # 根据你的设备更改端口号 baud_rate = 9600 # 波特率 bytesize = serial.EIGHTBITS # 数据位 pa 阅读全文
posted @ 2024-09-26 15:07 ganph 阅读(486) 评论(0) 推荐(0)