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地址清单

相关推荐
建筑转Java-张无忌22 分钟前
在Java中,什么是checked exception(即compile-time exception、编译时异常)?
java·开发语言
FL162386312922 分钟前
基于yolov11的打电话玩手机检测系统python源码+pytorch模型+评估指标曲线+精美GUI界面
python·yolo·智能手机
动能小子ohhh32 分钟前
Python中的客户端和服务端交互的基本内容
开发语言·python
stevenzqzq40 分钟前
kotlin 05flow -从 LiveData 迁移到 Kotlin Flow 完整教程
android·开发语言·kotlin·flow
hongjianMa44 分钟前
【论文阅读】Joint Deep Modeling of Users and Items Using Reviews for Recommendation
论文阅读·python·深度学习·卷积神经网络·推荐系统·推荐算法·多模态
HelloRevit1 小时前
DXFViewer进行中 : ->封装OpenGL -> 解析DXF直线
开发语言·c++
Pocker_Spades_A1 小时前
[C语言]第一章-初识
c语言·开发语言·vscode
GanGuaGua2 小时前
C语言:文件操作
c语言·开发语言
豆芽脚脚2 小时前
Auto.js 脚本:清理手机数据但保留账号
开发语言·javascript·智能手机·autojs
编程有点难3 小时前
Python训练打卡Day16
开发语言·python