- 博客(23)
- 收藏
- 关注
原创 Error: unable to perform an operation on node ‘rabbit@Aron‘. Please see diagnostics...
Error: unable to perform an operation on node 'rabbit@Aron'. Please see diagnostics information and suggestions below.
2022-09-20 13:52:42 2069
原创 python 去除字符串中非字母和数字的元素
一行代码去除字符串中非字母和数字的元素from loguru import loggers = 'fdsa49376!@&#h3!@#'res = ''.join(filter(lambda c: c.isalpha() or c.isdigit(), s))logger.info(res) # fdsa49376h3
2022-05-20 10:32:35 903
翻译 python安装playwright
playwright安装:python为3.7以上版本如果没安装python或版本过低,可以去官网下载 python官网链接安装playwright及Chromium、Firefox和WebKit的浏览器二进制文件pip安装pip install --upgrade pippip install playwrightplaywright installconda安装conda config --add channels conda-forgeconda config --add cha
2022-02-17 17:53:14 3127
原创 记录 Python dict使用误区
这两天写代码是用了列表里面追加字典的操作,代码如下:tmp_datas = [{'a': 18}, {'a':20}]def test(tmp_datas): tmp_li = [] tmp_dic = {} for data in tmp_datas: tmp_dic['age'] = data['a'] tmp_li.append(tmp_dic) print(tmp_li)test(tmp_datas)由于字典是可变数据
2022-01-13 23:55:02 222
原创 ValueError: Invalid header name b‘:authority‘
爬虫时,为了防止headers身份验证的显示,通常会将Chrome中的Request Headers拿过来转化成需要的headers的字典格式
2021-11-11 21:34:37 2334 4
原创 Python:查找列表或字符串中出现最频繁的值
比较取最大值test = [1, 2, 3, 2, 4, 5, 2, 3, 7, 8]a = 0max_str = 0for i in test: if test.count(i) > a: a = test.count(i) max_str = iprint("test中出现频率最大的值为%s,共出现了%s次" % (max_str, a))max函数(代码简洁,推荐使用)test = [1, 2, 3, 2, 4, 5, 2, 3.
2021-11-01 09:35:28 1035
翻译 Python的Playwright - 1.4 Download
Download对象由页面通过page.on(" Download ")事件分派from playwright.sync_api import sync_playwrightwith sync_playwright() as sp: browser = sp.chromium.launch(headless=False) context = browser.new_context(accept_downloads=True) page = context.new_page()
2021-09-24 20:15:03 1573
翻译 Python的Playwright - 1.3 Dialog
Dialog对象用来侦听对话框操作,alert,beforeunload(在文档即将被卸载之前发生此事件),confirm或prompt等
2021-09-24 18:32:59 1474
翻译 Python的Playwright - 1.2 ConsoleMessage
`ConsoleMessage`对象通过page.on("console")事件按页面调度
2021-09-24 15:12:06 585
翻译 Python的Playwright - 1.1 BrowserContexts
`BrowserContexts`提供了一种操作多个独立浏览器会话的方法,如果一个页面打开另一个页面,例如通过window.open调用,弹出窗口将属于父页面的浏览器上下文。
2021-09-23 18:23:38 3181
翻译 Python的Playwright
API:playwright官网Playwright 模块提供了一种启动浏览器实例的方法。以下是使用 Playwright 驱动自动化的典型示例:from playwright.sync_api import sync_playwrightdef run(playwright): chromium = playwright.chromium # or "firefox" or "webkit". browser = chromium.launch() page = brows
2021-09-22 16:18:40 3166
原创 使用playwright将文件快速转换成pdf格式
1. 安装Conda安装:conda config --add channels conda-forgeconda config --add channels microsoftconda install playwrightplaywright installPip安装:# 安装playwrightpip install playwright# 安装browser驱动playwright install2. 利用playwright 将page保存为pdf格式的用法playwr
2021-08-27 20:02:55 1252
原创 Python: 用代码了解async中的await
查很多关于async & await的相关资料时,对于异步函数的解释,大多数都是用多个异步函数同时执行的方式来解释运行轨迹,虽然知道await是让Awaitable对象挂起,但还是对其作用一知半解,通过debug工具调试了之后,才明白了一点,希望下面的代码能帮助你加深对await的了解 ~ ~先定一两个异步函数import asyncioimport timeasync def main(para): result_val = await as_func(para) print("--
2021-08-18 16:22:03 398
原创 MySQL实操学习笔记
结绳记事 - 甲骨记事 - 图书馆 - 文件 - 数据库数据库的优点: - 持久化存储 - 读写速度极高 - 保证数据的有效性 - 对程序支持性非常好,容易扩展关系型数据库核心元素: - 数据行(记录) - 数据列(字段) - 数据表(数据行的集合) - 数据库(数据表的集合) RDBMS - Relational Database Management System - 通过表来表示关系型 当前主要使用的两种数据库:关系型数据库和非关系型数据库 关系型数据库RD
2021-08-03 20:45:58 205
原创 python中yield和yield from的区别(附代码理解)
s_list = ['a','b','c',]def generator_1(li): yield icounter = 0for i in generator_1(s_list): counter += 1 print(i) print(counter)# 输出: ['a','b','c'] 1s_list = ['a','b','c',]def generator_2(li): yield from licounter = 0for i in generator_2
2021-06-10 21:30:26 1773 2
原创 Shell#重定向# 清空文件
最近使用sed命令的时候遇到了一个小问题,来此记录下当执行命令:#sed '/#/d' file.txt >file.txt 预想的结果是:把file.txt文件里带有"#"的行清空,然后重定向到file.txt,但结果是file.txt文件是空的。 其实出现这种情况的原因很简单,就是了解一下重定向(>)机制:创建或清空目标文件将前面输出的内容重定向到目标文件 如果输入文件和输出文件一致的话,做第一步清空输出文件的时候,输入文件同时被清空了,所以无论做什么操作,目的文件
2020-11-06 18:54:58 473
原创 简单的理解文件和目录的区别
我们的目录里面存的是文件的索引,相当于一本书的目录,可以在目录里面查看文件名和inode name,所以目录一般占用的空间不大,真正占空间的是文件。而文件里存的是数据。目录和文件重要的区别是在r,w,x的作用上面:权限对文件的影响对目录的影响读(r)可以读取文件内容可以列出目录的内容写(w)可以更改文件内容可以创建或删除目录中的任一文件执行(x)可以作为命令执行文件可以访问目录的内容(取决于目录文件的权限)之所以对上面的内容:“可以创建或删除目录中的任
2020-05-22 16:24:10 6122
翻译 Python:给定两个列表,找出相同元素和不同元素
list1 = [1, 2, 4]list2 = [3, 4, 5]set1 = set(list01)set2 = set(list02)print(set1 & set2)print(set1 ^ set2)输出结果为:{4}{1, 2, 3, 5}
2019-01-22 16:21:11 10182 1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人