Python 判断数组是否为空 在Python中,None、空字符串””、0、空列表[]、空字典{}、空元组()都相当于 False,非空则返回 True。 123456789101112131415161718192021222324252627282930313233array = []if not array: print("数组为空")else: print("数组不为空&quo 2025-03-25 随笔 #Python
Bleak 使用指北 发现任意蓝牙设备123456789import asynciofrom bleak import discoverasync def discover_bluetooth(): devices = await discover(timeout=5.0) for d in devices: print(d)asyncio.run(discover_bluetooth()) 2025-03-19 随笔 #Bluetooth
树莓派扫描蓝牙信标 Beacon 方案 beacontoolsbeacontools 按照 Readme 进行部署后,仍然无法运行示例代码,原因在于: 12from bluetooth import _bluetooth as bluezModuleNotFoundError: No module named "bluetooth" 即缺少了 pybluez 的相关内容。 但是在历经千辛万苦成功安装上 pyblue 2025-03-18 合集 #Bluetooth #Python #Raspberry Pi #Beacon
Mac M 芯片睡眠后反复唤醒外接显示器异常解决方案 贴几个相关的问题: Mac睡眠时经常异常唤醒问题的处理 升级 macOS Monterey 后设备休眠半夜频繁唤醒问题 外置屏幕频繁被唤醒又休眠。这是 m1 的通病? M2 外接显示器睡眠后频繁唤醒 M1 Mac 睡眠后老是点亮 U2720Q 解决方案: 使用指令 pmset -g 后,注意到有蓝牙阻止了 Mac 进入到睡眠。由于我用的是妙控板,所以只可能是键盘的问题。 在 Mac 睡眠时关闭 2025-02-24 随笔 #Mac
SwiftUI 调整 View 在 Stack 中的高度或者宽度占比 1234567891011121314151617181920import SwiftUIstruct ContentView: View { var body: some View { VStack(spacing: 0) { Rectangle() .fill(Color.red) 2025-01-16 随笔 #SwiftUI
SwiftUI Spacer() 部分无法响应点击 12345678910111213struct ContentView: View { var body: some View { VStack { Text("可以点击文字 1") Spacer() Text("可以点击文字 2") 2025-01-16 随笔 #SwiftUI
SwiftUI 右侧 Sidebar 1234567891011121314struct ContentView: View { @State var showInspector = false var body: some View { Text("Hello Word") .toolbar { Button(action 2025-01-16 随笔 #SwiftUI
SwiftUI 隐藏 NavigationSplitView 的 detail 123456789101112NavigationSplitView { Text("Sidebar")} content: { Text("Content")} detail: { if detailViewVisible { Text("Detail&q 2025-01-16 随笔 #SwiftUI
git 添加 .gitignore 文件忽略 .DS_Store 添加 .gitignore 文件macOS 上传代码到 git 时,会把 .DS_Store 文件也一并上传。在没用的同时,还很影响项目的阅读。 所以需要用到 .gitignore 来忽略不需要上传 git 的文件或者文件夹: cd 到项目文件夹,输入: 1touch .gitignore 创建 .gitignore 文件。Command+Shift+. 可以显示隐藏文件。 打开 .gitign 2025-01-16 随笔 #git
SwiftUI macOS 让 TextField 失去焦点 这串代码的作用是让 iOS 键盘收起,同时也能让 macOS 的 TextField 失去焦点: 123DispatchQueue.main.async { NSApp.keyWindow?.makeFirstResponder(nil)} 在 macOS 中,选中 TextField 按下键盘回车并不会使其失去焦点。正确的做法是: 123456// 回车确认.onSubmi 2025-01-15 随笔 #SwiftUI