当前位置:首页 > 日记本

Python 正则表达式 带分组的替换 \g

zhangchap3年前 (2021-06-16)314
import re re.sub(r'([^a-z]*)[a-z]([^a-z]*)', '\g<1>\g<2>',wor...

python fake_useragent 模块用法

zhangchap3年前 (2021-06-01)318
我们每次发送requests请求时通过random从中随机获取一个随机UserAgent,两行代码即可完成UserAgent的不停更换 from fake_useragent i...

python读取txt文件放到Queue队列

zhangchap3年前 (2021-05-29)443
from queue import Queue with open('kw.txt',encoding='utf-8')&nb...

python url.parse模块编码解码

zhangchap3年前 (2021-05-29)299
from urllib.parse import quote,unquote,urlencode # 对汉字进行编码使用 quote ...

python 获取当前时间及随机时间戳

zhangchap3年前 (2021-05-26)333
import time from random import randint time.strftime('%Y-%m-%d %H:%M:...

python 发布文章 随机分类(choice)

zhangchap3年前 (2021-05-26)311
from random import choice catid = choice([5,6]) #choice 函数从列表中随机提取...

python jieba分词

zhangchap3年前 (2021-05-25)269
import jieba from jieba.analyse import tfidf words = jieba.lcut('...

python 随机生成时间戳写入txt文件/运行sql语句

zhangchap3年前 (2021-05-20)479
import time from random import randint with open('time.txt', ...

python xpath语法总结

zhangchap3年前 (2021-05-20)249
python xpath语法总结:常用的://1.从任意节点开始/2.从根节点开始//div/p3.div下的p标签//div[@class="hrzz_bottom"]/ul/l...

python补全网址代码示例

zhangchap3年前 (2021-05-19)357
from urllib.parse import urljoin absurl = urljoin(backend,url) #backend:根...