Python 虚拟环境与依赖导出
因为不同的项目之间可能存在依赖冲突,因此需要使用虚拟环境,避免在全局环境上安装依赖。
Python 依赖导出
通过 pipreqs 可以将当前项目依赖的所有包导出到 requirements.txt 中:
1$ pipreqs . --encoding=utf8 --force 因为不同的项目之间可能存在依赖冲突,因此需要使用虚拟环境,避免在全局环境上安装依赖。
通过 pipreqs 可以将当前项目依赖的所有包导出到 requirements.txt 中:
1$ pipreqs . --encoding=utf8 --force Python 的异步 I/O 基于协程实现。使用async关键字来创建一个异步函数,对异步函数的调用不会执行该函数,而是生成一个协程对象。
对每一个协程对象,都必须等待其结束(即使是没有启动的协程),否则会产生一个RuntimeWarning。
示例 :
1# 创建一个异步函数
2async def say_hello():参考:
首先在 X11 上剪切板被称作 Selections,系统上可以有任意多个 Selections,并且有三个预定义的标准 Selections:
primary - 当前选中的文本,例如终端上点击鼠标中键可以立即粘贴选中的文本secondary - 没有被使用clipboard - 通常意义上的剪切板,不同进程间交换数据时使用它通过 xcb_get_image 可以进行截图:
1xcb_get_image_cookie_t
2xcb_get_image (xcb_connection_t *c, // X连接
3 uint8_t format, // 格式
4 xcb_drawable_t drawable, // 要截图的目标,例如窗口,截全屏则为 root 窗口
5 int16_t x, // 截图的起点 x 坐标1// 获取窗口事件
2#include <stdio.h>
3#include <xcb/xcb.h>
4
5int main()1typedef struct xcb_query_pointer_reply_t {
2 uint8_t response_type;
3 uint8_t same_screen;
4 uint16_t sequence;
5 uint32_t length;
6 xcb_window_t root;
7 xcb_window_t child;1// gcc main.c -lX11 -lXss
2#include <stdio.h>
3#include <X11/extensions/scrnsaver.h>
4
5int main(void)
6{
7 Display* dpy = XOpenDisplay(NULL);在使用 Linux 的时候,如果经常进行升级,时不时会遇到驱动失效的问题:
1$ nvidia-smi
2NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver.
3Make sure that the latest NVIDIA driver is installed and running.1$ nvidia-smi
2NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.
3
4$ dkms status
5nvidia, 470.86, 5.13.0-22-generic, x86_64: installed升级时失败
1sudo apt update
2sudo apt upgrade错误信息: