05 2021 档案

摘要:esp32没有pyb库 ,所以需要自己实现 from machine import Pin, PWM import time pin = Pin(13) # 数据线插13引脚 pwm = PWM(pin, freq=50) while True: pwm.duty(40) time.sleep(1) 阅读全文
posted @ 2021-05-26 20:58 忆秋年枫叶情 阅读(1394) 评论(0) 推荐(0)
摘要:编码 import ubinascii baseBy= ubinascii.b2a_base64(bytes) # 1. 编码后是base64的bytes数组 # 使用 baseBy.decode("utf-8") 转成字符串 解码 import ubinascii ubinascii.a2b_ba 阅读全文
posted @ 2021-05-25 17:34 忆秋年枫叶情 阅读(1506) 评论(0) 推荐(0)
摘要:进制转换 bin(10) # 转二进制 oct(100) # 转八进制 int(10) # 转十进制 hex(255) # 转十六进制 chr(97) # 转字符串。chr(97) 返回字符串 'a' ord("a") # 转整数。ord('a') 返回整数 97 四舍五入 round(3.1414 阅读全文
posted @ 2021-05-25 15:14 忆秋年枫叶情 阅读(47) 评论(0) 推荐(0)
摘要:实际访问地址 http://xxx.com/test/api/micro/GetDev 代理后 将url中test替换掉 http://xxx.com/api/micro/GetDev ##修改 Nginx 配置文件 nginx.conf 中 server 节点 location /test/ { 阅读全文
posted @ 2021-05-22 12:02 忆秋年枫叶情 阅读(1286) 评论(0) 推荐(0)
摘要:GPIO 设置模式 from machine import Pin p = Pin(27, Pin.OUT) p.value(1) # 设置为高电平 p.value(0) # 设置为低电平 GPIO 读取模式 from machine import Pin p = Pin(27, Pin.IN) r 阅读全文
posted @ 2021-05-19 15:03 忆秋年枫叶情 阅读(340) 评论(0) 推荐(0)
摘要:工具→选项→项目和解决方案 阅读全文
posted @ 2021-05-15 18:53 忆秋年枫叶情 阅读(214) 评论(0) 推荐(0)
摘要:Math 1. 绝对值 Math.Abs() 2. 四舍五入 Math.Round() 3. 向上取整 Math.Ceiling() 4. 向下取整 Math.Floor() 阅读全文
posted @ 2021-05-12 14:24 忆秋年枫叶情 阅读(118) 评论(0) 推荐(0)
摘要:dotnet core c# 大文件 读取 //注册编码提供程序 Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); //实例 using var sr = new System.IO.StreamReader(@"E:\Au 阅读全文
posted @ 2021-05-11 11:32 忆秋年枫叶情 阅读(224) 评论(0) 推荐(0)
摘要:时间同步 校准 官方同步库 ntptime def sync_ntp(): """通过网络校准时间""" import ntptime ntptime.NTP_DELTA = 3155644800 # 可选 UTC+8偏移时间(秒),不设置就是UTC0 ntptime.host = 'ntp1.al 阅读全文
posted @ 2021-05-11 09:55 忆秋年枫叶情 阅读(4546) 评论(0) 推荐(0)
摘要:utime 本地时间 import utime utime.localtime() 时间戳(秒) 时间戳是以模块rtc时钟初始值以起点计算的秒数 如esp32模块的rtc初始时钟是 2000年1月1日 import utime utime.mktime(utime.localtime()) #esp 阅读全文
posted @ 2021-05-10 21:01 忆秋年枫叶情 阅读(2171) 评论(0) 推荐(0)
摘要:JSON 1. 对象 → 字符串 import ujson jsonObj = {"a": "1", "b": "2"} jsonStr = ujson.dumps(jsonObj) 2. 字符串 → 对象 import json jsonStr = '{"a": "1", "b": "2"}' j 阅读全文
posted @ 2021-05-10 20:44 忆秋年枫叶情 阅读(465) 评论(0) 推荐(0)
摘要:SHA256 SHA256-SHA2系列的最新现代哈希算法。它适用于加密安全的目的。 import uhashlib import ubinascii ## 常规 text = b'123' # 需要加密的数据 或 "123".decode("utf8") hash = uhashlib.sha25 阅读全文
posted @ 2021-05-10 20:35 忆秋年枫叶情 阅读(514) 评论(0) 推荐(0)
摘要:完整示例 (控制台) using System; using System.Collections.Generic; using System.Diagnostics; using System.Net.Http; using System.Threading; using System.Threa 阅读全文
posted @ 2021-05-09 11:34 忆秋年枫叶情 阅读(147) 评论(0) 推荐(0)
摘要:示例 try: pass except (Exception, OverflowError, AttributeError): #捕获多个异常 print("发生了异常执行") pass else: print("没发生异执行") pass finally: print("finally") pas 阅读全文
posted @ 2021-05-09 11:33 忆秋年枫叶情 阅读(78) 评论(0) 推荐(0)
摘要:import time # 当地时间 time.localtime() # (tm_year=2021, tm_mon=5, tm_mday=3, tm_hour=19, tm_min=50, tm_sec=40, tm_wday=0, tm_yday=123, tm_isdst=0) time.s 阅读全文
posted @ 2021-05-09 11:30 忆秋年枫叶情 阅读(750) 评论(0) 推荐(0)
摘要:文档: https://www.pycryptodome.org/en/latest/ # pip install pycryptodome from Crypto.Cipher import AES import base64 class Encrypt: def __init__(self, k 阅读全文
posted @ 2021-05-09 11:29 忆秋年枫叶情 阅读(554) 评论(0) 推荐(0)
摘要:import asyncio import time async def say_after(delay, what): """使用 async 声明函数""" await asyncio.sleep(delay) print(what) async def main(): # 一个一个执行 pri 阅读全文
posted @ 2021-05-09 11:27 忆秋年枫叶情 阅读(58) 评论(0) 推荐(0)
摘要:示例 # pip install aiohttp import asyncio import aiohttp headers = { "Referer": "https://vod.bunediy.com", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; 阅读全文
posted @ 2021-05-09 11:24 忆秋年枫叶情 阅读(214) 评论(0) 推荐(0)
摘要:GBK编码格式 Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); var encoBytes= Encoding.GetEncoding("gbk").GetString(resBytes); 阅读全文
posted @ 2021-05-08 17:09 忆秋年枫叶情 阅读(426) 评论(0) 推荐(0)
摘要:包安装 nuget包名 HtmlAgilityPack 文档地址 https://html-agility-pack.net/documentation 加载 // 文件加载 var doc = new HtmlDocument(); doc.Load(filePath); // 字符串加载 var 阅读全文
posted @ 2021-05-08 16:33 忆秋年枫叶情 阅读(218) 评论(0) 推荐(0)