Python 正则表达式 带分组的替换 \g
import re re.sub(r'([^a-z]*)[a-z]([^a-z]*)', '\g<1>\g<2>',wor...
python fake_useragent 模块用法
我们每次发送requests请求时通过random从中随机获取一个随机UserAgent,两行代码即可完成UserAgent的不停更换 from fake_useragent i...
python读取txt文件放到Queue队列
from queue import Queue with open('kw.txt',encoding='utf-8')&nb...
python url.parse模块编码解码
from urllib.parse import quote,unquote,urlencode # 对汉字进行编码使用 quote ...
python 获取当前时间及随机时间戳
import time from random import randint time.strftime('%Y-%m-%d %H:%M:...
python 发布文章 随机分类(choice)
from random import choice catid = choice([5,6]) #choice 函数从列表中随机提取...
python jieba分词
import jieba from jieba.analyse import tfidf words = jieba.lcut('...
python 随机生成时间戳写入txt文件/运行sql语句
import time from random import randint with open('time.txt', ...
python xpath语法总结
python xpath语法总结:常用的://1.从任意节点开始/2.从根节点开始//div/p3.div下的p标签//div[@class="hrzz_bottom"]/ul/l...
python补全网址代码示例
from urllib.parse import urljoin absurl = urljoin(backend,url) #backend:根...