微信接龙-未接龙人名单

前言

不论是学校也好,还是个人单位也好。在推送通知的时候,通过接龙的方式确定每个人是否收到是非常方便的。

但是微信接龙只有谁接了龙,谁没有接龙是未知的。微信也没有提供相关功能。

人太多的时候根本没有办法知道 是谁 没接龙。

所以就写了一个脚本进行未接龙成员的判断。脚本的核心是一个正则判断[1][2]。

用的笨办法,大家包容一下ヾ(≧▽≦*)o。

1 代码

1.1 伪代码

  1. 首先设置两个文本文件
    • string_total.txt: 在过去的接龙中找到一个所有人都接龙的文本。(应接龙)
    • string_now.txt: 本次接龙的最终文本。(实接龙)
  2. 通过正则表达式将这两个中的人名提取出来。
  3. 若 应接龙人 不在 实接龙人里 就加入 未接龙人里。

1.2 python 代码

"""
version 1.1
time: 2022.9.29
author:cnblog-Dba_sys
"""

import re

def split_name(string):
        names = re.findall(r'\d+\..(.+)', string)
        return names

def get_content(path):
        print("reading: ", path)
        with open(path, 'r', encoding = 'utf-8') as f:
                content = f.read()
        return content

def show(list_obj, string_obj):
        print("")
        print(string_obj)
        print("names:", list_obj)
        print("number:", len(list_obj))
        print("")

string_total = get_content("string_total.txt")
string_now = get_content("string_now.txt")


name_list = split_name(string_total)
show(name_list, "-Should be received-")

names = split_name(string_now)
show(names, "-Acually received-")


not_received = []
for name in name_list:
        if name not in names:
                not_received.append(name)
                
show(not_received, "-Not received-")

1.3 运行结果

2 使用方式

2.1 描述

  1. 创建文件夹 weixin_jielong
  2. 创建 not_receive.py 子文件
  3. 创建 string_total.txt 子文件,即将一个完整的接龙文档复制即可。
  4. 创建 string_now.txt 子文件,即将本次的接龙文档复制即可。

2.2 结构

weixin_jielong
	|___not_receive.py
	|___string_total.txt
	|___string_now.txt

运行图

  • string_total.txt
    image

  • run
    image

引用:
[1]菜鸟教程-正则表达式:https://www.runoob.com/regexp/regexp-tutorial.html
[2]正则表达式可视化工具:https://www.runoob.com/regexp/regexp-tutorial.html

本文由Dba_sys创作,首发于博客园。2022.9.29
文章会随时改动,要到博客园里看偶。一些网站会爬取本文章,但是可能会有出入。
引用或转载请注明出处哦( ̄︶ ̄)↗
https://www.cnblogs.com/asmurmur/

posted @ 2022-09-29 09:41  Dba_sys  阅读(372)  评论(0编辑  收藏  举报