07 2023 档案
把字符串中的所有br标签换成连续两个br标签
摘要:# 把所有br标签换成一个br标签content = re.sub(r"(<br>)\1+", r"\1", content)# 把一个换成2个br标签content = re.sub("<br>", '<br><br>', content)print(f'展示图片原图片:{picurl}')
mysql 插入数据时,出现"\xF0\x9F\x8F\x80"这种情况的处理!
摘要:删除内容中的表情符号 import emoji import re def del_emoji(text): text = emoji.demojize(text) result = re.sub(':\S+?:', ' ', text) result = result.replace("(●'◡'
删除img标签里的width和height属性,并在img标签前后加一个br标签
摘要:# 提取img标签 tree_img = etree.HTML(content) width = tree_img.xpath('//img//@width')[0] height = tree_img.xpath('//img//@height')[0] # 替换掉width=,和height=
矿机之家
摘要:import hashlib import random import re import time from lxml import etree import pymysql import requests def strip_tags(string, allowed_tags=''): if a
多个列表组合成一个字典
摘要:list1 = ['组', '2023-1-1', '2023-1-2', '2023-1-3', '总业绩'] list2 = ['一组', '1', '2', '3', '6'] list3 = ['二组', '4', '5', '6', '15'] list4 = ['三组', '7', '8
任意长度列表三三分割,组成一个列表套列表的新列表
摘要:list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] # 输出结果[1,2,3][4,5,6][7.8.9] len_list = len(list) // 3 num_list = len(list) % 3 list_all = [] for num in range(l
保留内容中的特定标签
摘要:def strip_tags(string, allowed_tags=''): if allowed_tags != '': # Get a list of all allowed tag names. allowed_tags = allowed_tags.split(',') allowed_