Python之禅

如何显示? import this The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face

AWS CLI S3 从存储桶下载和上传文件

可以使用 cp 复制,或 sync 同步,或者 mv 移动 https://docs.aws.amazon.com/cli/latest/reference/s3/cp.html 单个文件的下载和上传下载文件 aws s3 cp <S3Uri> <LocalPath> 上传文件 aws s3 cp <LocalPath> <S3Uri> S3Uri 格式:s3://bucket-name/ob

AWS 在IAM控制台创建管理员账号

创建一个管理员账号 打开 IAM 控制台 ,选择创建一个管理员账号 Add User Access type 选上 Programmatic access Permissions 选 Attach existing policies directly。然后 Policy 选 AdministratorAccess 下一步,直到显示 Access Key ID 和 Secret Access Key 页

JS 生成随机字符串

Generate random characters Math.random().toString(36).replace(/[^a-z]+/g, '').slice(0, 5); Math.random(),生成随机数,例如:0.09751664076957856 .toString(36),转换成36进制后

Python 遍历指定目录下的文件

列出指定目录下的全部文件,或可以通过扩展名指定文件类型,也可以通过指定排除规则,忽略部分文件。 def list_files( dir: str, ext: list = None, recursive: bool = True, excludes: list = None ): """ Args: - dir, directory path.

Qt Pyside2 访问剪贴板

Qt/Pyside2 读取系统剪贴板内容 import sys from PySide2.QtWidgets import QApplication app = QApplication(sys.argv) clipboard = app.clipboard() print(clipboard.mimeData().formats()) print(clipboard.mimeData().data(clipboard.mimeData().formats()[0])) app.closeAllWindows() app=None mimeData() 就和 drag 时对 mimeData() 的操作一样了。 引用自 doc.qt.io: QClipboard supports the same data types that QDrag does, and uses similar mechanisms. For advanced clipboard usage read Drag and Drop .

Shell use clipboard to copy and paste

copy copy text file content to clipboard pbcopy < file.txt copy command stdout to clipboard ps aux | pbcopy copy text echo text | pbcopy paste paste from clipboard to file pbpaste > file.txt filter string pbpaste | grep "hello" > file2.txt echo text from clipboard echo | pbpaste Reference https://www.macobserver.com/tips/quick-tip/use-clipboard-in-terminal-without-mouse/