0%

1
2
pip install pyqt5 -i https://mirrors.aliyun.com/pypi/simple/
pip install PyQt5-tools -i https://mirrors.aliyun.com/pypi/simple/

File | Settings | Tools | External Tools 添加 QtDesigner

QtDesigner Qt

选择 venv\Lib\site-packages\qt5_applications\Qt\bin\designer.exe

工作目录选择 $ProjectFileDir$

PyUIC主要是把Qt Designer生成的.ui文件换成.py文件。

Name: PyUIC

Program : D:\Program Files\Python36\python.exe # 当前Python目录,请根据实际修改

Arguments: -m PyQt5.uic.pyuic $FileName$ -o $FileNameWithoutExtension$.py

Working directory: $FileDir$

PyRCC主要是把编写的.qrc资源文件换成.py文件。

Name: PyRCC

Program: D:\Program Files\Python36\pyrcc5.exe # 当前rcc工具目录,请根据实际修改

Arguments: $FileName$ -o $FileNameWithoutExtension$_rc.py

Working directory: $FileDir$

本文地址: https://github.com/maxzhao-it/blog/post/dfa7f0a1/

操作文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import os
import shutil
from datetime import datetime
from urllib.request
from requests

downloadUrl = 'https://alist.qyide.com'
fileFullPath = 'd:/23.png'
urllib.request.urlretrieve(downloadUrl, filename=fileFullPath)
# 或者
file = requests.get(downloadUrl, allow_redirects=True, headers={
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36'
})
open(fileFullPath, 'wb').write(file.content)

本文地址: https://github.com/maxzhao-it/blog/post/6071409/

简单切换2和3

1
2
3
yum install -y python python3 python3-devel
alias python = python3
python3 --version

版本管理

1
2
3
4
5
6
7
8
9
10
11
12
13
yum install -y anaconda
conda create --name py3.7 python=3.7
conda activate py3.7
conda deactivate
# 安装
conda install numpy
conda list
conda search numpy
conda update numpy
conda update --all
conda update conda
conda update python
conda env list

设置国内源

1
2
3
4
5
6
7
8
conda config --show channels
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud//pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --show channels
# 搜索显示地址
conda config --set show_channel_urls yes

直接配置

1
vim ~/.condarc

清华

1
2
3
4
5
6
7
8
9
10
11
12
13
14
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

阿里

1
2
3
4
5
6
7
8
9
10
11
12
13
14
channels:
- defaults
show_channel_urls: true
default_channels:
- http://mirrors.aliyun.com/anaconda/pkgs/main
- http://mirrors.aliyun.com/anaconda/pkgs/r
- http://mirrors.aliyun.com/anaconda/pkgs/msys2
custom_channels:
conda-forge: http://mirrors.aliyun.com/anaconda/cloud
msys2: http://mirrors.aliyun.com/anaconda/cloud
bioconda: http://mirrors.aliyun.com/anaconda/cloud
menpo: http://mirrors.aliyun.com/anaconda/cloud
pytorch: http://mirrors.aliyun.com/anaconda/cloud
simpleitk: http://mirrors.aliyun.com/anaconda/cloud

本文地址: https://github.com/maxzhao-it/blog/post/7b8773dd/

操作

1
2
3
4
pip install beautifulsoup4 -i https://mirrors.aliyun.com/pypi/simple/
pip install lxml -i https://mirrors.aliyun.com/pypi/simple/
pip install html5lib -i https://mirrors.aliyun.com/pypi/simple/
pip install chardet -i https://mirrors.aliyun.com/pypi/simple/
1
2
3
4
5
6
7
8
9
10
11
12
import chardet
from bs4 import BeautifulSoup
import requests
def loadTab1():
response = requests.get("https://wo", headers=headers)
if response.status_code != 200:
print('错误响应:', response.text)
return
response.encoding = requests.utils.get_encodings_from_content(response.text)[0]
parsed_html = BeautifulSoup(response.text, from_encoding='utf-8')
parsed_html.find()
print(response.text)

本文地址: https://github.com/maxzhao-it/blog/post/f33d2bd5/

安装

1
2
3
yum install -y python3 python3-devel python3-pip gcc-c++ gcc  unzip
mkdir ~/.pip
vim ~/.pip/pip.conf

写入

1
2
3
4
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com

安装 conda

1
2
3
4
# Install conda for Linux, for other OS download miniconda at https://docs.conda.io/en/latest/miniconda.html
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/miniconda
$HOME/miniconda/bin/conda init bash

添加环境变量 vim ~/.bashrc 写入 export PATH=$PATH:$HOME/miniconda/bin/
配置国内源 vim ~/.condarc

项目中安装

1
2
3
4
5
6
conda env create -f conda_env.yml
conda activate lama
conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch -y
pip install pytorch-lightning==1.2.9
# 最后退出
conda deactivate

问题:ModuleNotFoundError: No module named ‘skbuild’
pip3 install scikit-build -i https://mirrors.aliyun.com/pypi/simple/

配置环境

1
2
cd lama
export TORCH_HOME=$(pwd) && export PYTHONPATH=$(pwd)

安装 pre-trained models

当前方式已经无法下载 https://github.com/advimman/lama

本文地址: https://github.com/maxzhao-it/blog/post/2c1bc972/

JavaScript 执行 XPath

1
2
3
var a= document.evaluate("//span[text()='清单']/..", document, null, XPathResult.ANY_TYPE, null);
var b=a.iterateNext();
b

XPath定位方法

以下XPath定位方法,都可以动态组合,需要用 /// 分割定位函数。

/:当前元素的下一级

//:当前元素的所有子

通过元素名称定位

1
2
//div
//span

通过元素属性定位

1
2
3
//*[@attribute='value']
//*[@id='myId']
//div[@id='myId']

通过多个属性定位

1
2
3
//*[@attribute1='value' and @attribute2='value']
//*[@class='myClass' and @name='myName']
//div[@class='myClass' and @name='myName']

通过复杂属性行为

1
2
//*[contains(concat(' ', normalize-space(@class), ' '), ' myClass ')]
//div[contains(concat(' ', normalize-space(@class), ' '), ' myClass ')]

通过元素文本内容定位

1
2
3
//*[text()='text']
//div[text()='text']
//button[text()='submit']

通过父级元素定位子元素

1
2
//div/span   查询div直接子集下的span
//div//span 查询div所有子集的span

通过元素本身获取父级元素

1
2
3
//div/..
//div/../..
//*[attribute='value']/..

通过索引定位元素

1
2
(//div)[1]  下表从1开始
//div/span[1]

获取下一个元素

1
2
//div/following-sibling::div
//div/following-sibling::span
1
[not(contains(@style,'display: none;'))]

本文地址: https://github.com/maxzhao-it/blog/post/565f648c/

方案 vuepress-plugin-full-text-search2

vuepress2 推荐:

1
npm i -D vuepress-plugin-full-text-search2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import fullTextSearchPlugin from "vuepress-plugin-full-text-search2";
export default {
plugins: [
fullTextSearchPlugin({
locales: {
'/': {
placeholder: 'Search',
},
'/zh/': {
placeholder: '搜索',
},
},
}),
],
}

docs\.vuepress\styles\index.scss添加样式

1
2
3
4
5
6
7
8
9
10
11
12
// 搜索结果样式

.suggestions {
max-height: 80vh;
min-width: 80vh;
overflow-y: scroll;

.highlight {
color: #646cff;
font-weight: bold;
}
}

方案 vuepress-plugin-flexsearch-pro

方案 vuepress-plugin-next-search

方案 vuepress2-plugin-full-text-search

方案 fulltext-search

1
npm add -D vuepress-plugin-fulltext-search
1
2
3
4
// docs/.vuepress/config.js
module.exports = {
plugins: ['fulltext-search'],
}
1
2
3
4
5
---
search: false
---

<!-- page content -->

默认情况下,搜索关键字的结果是下划线,没有高亮。修改如下:

1
2
3
4
5
6
7
8
9
// 搜索结果样式
.suggestions {
max-height: 80vh;
overflow-y: scroll;
}
.suggestions .highlight{
color: #646cff
font-weight: bold
}

修改文件.vuepress/styles/index.style, 添加样式:高亮和加粗

本文地址: https://github.com/maxzhao-it/blog/post/66876dcb/

docs\.vuepress\config.ts

1
2
3
4
5
6
7
8
9
10
npm i -D vuepress-plugin-full-text-search2
npm i -D @vuepress/plugin-medium-zoom@next
npm i -D @vuepress/client@next
npm i -D @vuepress/plugin-back-to-top@next
npm i -D @vuepress/plugin-docsearch@next
npm i -D @vuepress/plugin-external-link-icon@next
npm i -D @vuepress/plugin-medium-zoom@next
npm i -D @vuepress/plugin-nprogress@next
npm i -D @vuepress/plugin-prismjs@next
npm i -D @vuepress/plugin-search@next
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { defaultTheme, defineUserConfig } from 'vuepress'
import { prismjsPlugin } from '@vuepress/plugin-prismjs'
import { searchPlugin } from '@vuepress/plugin-search'
import { backToTopPlugin } from '@vuepress/plugin-back-to-top'
import { externalLinkIconPlugin } from '@vuepress/plugin-external-link-icon'
import { nprogressPlugin } from '@vuepress/plugin-nprogress'
import { nav } from './nav'
import { sidebar } from './sidebar'
import fullTextSearchPlugin from "vuepress-plugin-full-text-search2";
import { mediumZoomPlugin } from '@vuepress/plugin-medium-zoom'
export default defineUserConfig({
lang: 'zh-CN',
title: 'maxzhao',
description: 'maxzhao',
/* 这里要使用绝对路径 */
head: [['link', { rel: 'icon', href: '/guide/images/logo.png' }]],
base: '/guide/',
dest: 'dist/guide',
port: 22222,
open: false,
theme: defaultTheme({
logo: '/images/home-logo.png',
logoDark: '/images/home-logo.png',
repo: 'https://gitlab.com/foo/bar',
// repoLabel: 'max',
navbar:nav,
// 侧边栏数组
// 所有页面会使用相同的侧边栏
sidebar: sidebar,
backToHome:'Back to home'
}),
plugins: [
fullTextSearchPlugin({
locales: {
'/': {
placeholder: 'Search',
},
'/zh/': {
placeholder: '搜索',
},
},
}),
// 返回顶部 按钮
backToTopPlugin(),
//语法高亮
prismjsPlugin({
// 配置项

}),
// Markdown 内容中的外部链接添加一个图标
externalLinkIconPlugin({
// 配置项
locales: {
'/': {
openInNewWindow: 'open in new window',
},
'/zh/': {
openInNewWindow: '在新窗口打开',
},
},
}),
// 页面进度条
nprogressPlugin(),
mediumZoomPlugin({
// 配置项
}),
],
})

docs\.vuepress\nav.ts

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

export const nav = [
{
text: 'home',
link: '/',
},
{
text: '版本',
children: [
'/version/version-1.0.3',
'/version/version-1.0.2',
'/version/version-1.0.1',
'/version/version-1.0.0',
'/version/',
],
},
]

docs\.vuepress\sidebar.ts

1
2
3
4
5
6
7
8
9

export const sidebar = {
'/version/': [
'/version/version-1.0.2',
'/version/version-1.0.1',
'/version/version-1.0.0',
'/version/',
]
}

本文地址: https://github.com/maxzhao-it/blog/post/af599b89/