python脚本练习
Published on 2022-07-28 20:52 in 分类: 02.编程语言 / 01.Python with Diligent_Maple

python脚本练习

    复制代码
    #从粘贴板读取输入,并简单筛选IP地址,打印至桌面并复制至粘贴板
    import
    pyperclip, re, os IpRegex = re.compile(r'''( (\d{1,3}) #IP address A class \. (\d{1,3}) #IP address B class \. (\d{1,3}) #IP address C class \. (\d{1,3}) #IP address D class )''', re.VERBOSE) text = str(pyperclip.paste()) matches = [] for groups in IpRegex.findall(text): matches.append(groups[0]) if len(matches) > 0: pyperclip.copy('\n'.join(matches)) print('\n'.join(matches)) else: print('No ip address.')
    复制代码

    缺失:

    1)未对IP地址是否合规进行判断,并且显示无法鉴别错误;

    2)不支持IPv6地址;

    ——————————————————————————————————————————————————————————————————————————————————————

    Python小白,逐步完善

    posted @   Diligent_Maple  阅读(37)  评论(0编辑  收藏  举报
    相关博文:
    阅读排行:
    · 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
    · 单线程的Redis速度为什么快?
    · SQL Server 2025 AI相关能力初探
    · AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
    · 展开说说关于C#中ORM框架的用法!
    历史上的今天:
    2020-07-28 磁盘分割
    点击右上角即可分享
    微信分享提示