Python-Mac格式转换脚本

一、原因:

将c4:ef:da:12:5c:53 变为 c4ef-da12-5c53

二、代码

复制代码
import re

mac_addresses = []

# Read the file
with open('client_list.txt', 'r') as file:
    # Read file contents into a list
    mac_addresses = [line.strip() for line in file]

# Process and print MAC addresses
for mac_address in mac_addresses:
    # Convert MAC address format from c4:ef:da:12:5c:53 to c4ef-da12-5c53
    mac = re.sub(r'[:]', '', mac_address)
    # Insert '-' every 4 characters
    mac = '-'.join(mac[i:i+4] for i in range(0, len(mac), 4))
    # Prepend 'sta ' to the MAC address
    mac = 'sta ' + mac
    print(mac)

三、需要在同一个目录下放置一个client_list.txt的文件放入你需要修改的mac地址清单

相关推荐
树獭非懒6 小时前
AI大模型小白手册|Embedding 与向量数据库
后端·python·llm
唐叔在学习9 小时前
就算没有服务器,我照样能够同步数据
后端·python·程序员
曲幽11 小时前
FastAPI流式输出实战与避坑指南:让AI像人一样“边想边说”
python·ai·fastapi·web·stream·chat·async·generator·ollama
Flittly11 小时前
【从零手写 AI Agent:learn-claude-code 项目实战笔记】(1)The Agent Loop (智能体循环)
python·agent
vivo互联网技术13 小时前
ICLR2026 | 视频虚化新突破!Any-to-Bokeh 一键生成电影感连贯效果
人工智能·python·深度学习
敏编程14 小时前
一天一个Python库:virtualenv - 隔离你的Python环境,保持项目整洁
python
喝茶与编码16 小时前
Python异步并发控制:asyncio.gather 与 Semaphore 协同设计解析
后端·python
zone773916 小时前
003:RAG 入门-LangChain 读取图片数据
后端·python·面试
用户83562907805116 小时前
在 PowerPoint 中用 Python 添加和定制形状的完整教程
后端·python