CSS 如何实现开关按钮(switch)

/attachments/3c3c91087455ce213729ff00352ce488.png

推荐使用现成的组件,不用重复造轮子。

  • Next.js 可以用 [nextui-org[(https://nextui.org/docs/components/switch)
  1. (关键)使用 <Label> 关联 <Input type=checkbox>,响应鼠标操作
    方法一:按照固定层级:<label><input /> <span or any other elment> </label>
    方法二:使用 labelfor 属性等于 input 的ID

Python 当前工作目录的路径

获取程序运行的工作目录。

  • 当前工作目录的相对路径
    os.curdir,是个常量,Unix-like 系统下是 .

  • 当前工作目录的绝对路径
    os.getcwd()os.path.abspath(os.curdir)

  • 当前工作目录的上级(父)目录的路径
    os.path.dirname(os.getcwd())

Python 获取当前程序脚本文件的路径

当前脚本/模块文件的路径,使用内置变量 __file__。注意“file”两端是各两个下划线。

当前工作目录,使用 os.getcwd() 方法。

For the directory of the script being run:

import pathlib
pathlib.Path(__file__).parent.resolve()

For the current working directory:

Python 创建多级目录(文件夹)

Python 创建文件夹,支持多级目录。

def make_dirs(dir_path):
    # 去除首尾空白符和右侧的路径分隔符
    dir_path = dir_path.strip().rstrip(os.path.sep)

    if dir_path:
        if not os.path.exists(dir_path):  # 如果目录已存在, 则忽略,否则才创建
            os.makedirs(dir_path)

AWS Lambda 为 Python 函数添加部署第三方库依赖项软件包

一种是和系统无相关性的程序包,例如一些纯 Python 代码写的程序包,即在本地开发环境和 Lambda 运行时环境中使用的程序包文件一样。
参见 AWS Lambda 准备无平台相关性的 Python 依赖项软件包

另一种是和系统有相关性的程序包,例如一些软件包根据系统不同,会用到不同的二进制文件。
参见 AWS Lambda 准备有平台相关性的 Python 依赖项程序包 (native code)