Keil C51 插件 快速复制一行

此插件解决的问题

目前 Keil 软件 只可以 先选中一行,再Ctrl C + Ctrl V , 太麻烦了

Keil 插件 -- Python 代码

python 复制代码
import sys


# 插入当前行内容
def insert_line(current_file_path, line_number):
    line_to_insert = ''

    # 读取文件内容
    with open(current_file_path, 'r', encoding='gb2312') as file:
        content = file.read()

    # 分割内容为行
    lines = content.splitlines()

    # 获取当前行 内容
    if line_number <= len(lines):
        line_to_insert = lines[line_number - 1]
    else:
        raise IndexError("Line number exceeds the total number of lines in the file.")

    # 插入新行
    lines.insert(line_number - 1, line_to_insert)

    # 将修改后的内容写回文件
    with open(current_file_path, 'w', encoding='gb2312') as file:
        file.write('\n'.join(lines) + '\n')


if __name__ == "__main__":
    try:
        filename = sys.argv[1:]

        file_path = ' '.join(filename[:-2]) + filename[-2].split('\\')[-1]

        row_num = int(filename[-1]) + 1

        insert_line(file_path, row_num)

        print('复制当前一行')

    except Exception as e:
        print(str(e))

需要修改的地方

上面代码,所需要的包,自行导入

Python 生成 exe

pip install pyinstaller -- 自行安装包

python 复制代码
pyinstaller -Fw .\Select_All_if.py 

Keil C51 插件安装

参数 自行复制

复制代码
$E !E ~E

效果

快捷键添加

不会改的,自行留言

相关推荐
AAD555888991 天前
数字仪表LCD显示识别与读数:数字0-9、小数点及单位kwh检测识别实战
python
Amrzs_hp1 天前
stm32温度采集
stm32·单片机·嵌入式硬件
开源技术1 天前
Python Pillow 优化,打开和保存速度最快提高14倍
开发语言·python·pillow
Li emily1 天前
解决港股实时行情数据 API 接入难题
人工智能·python·fastapi
wfeqhfxz25887821 天前
农田杂草检测与识别系统基于YOLO11实现六种杂草自动识别_1
python
mftang1 天前
Python 字符串拼接成字节详解
开发语言·python
0思必得01 天前
[Web自动化] Selenium设置相关执行文件路径
前端·爬虫·python·selenium·自动化
石去皿1 天前
大模型面试通关指南:28道高频考题深度解析与实战要点
人工智能·python·面试·职场和发展
jasligea1 天前
构建个人智能助手
开发语言·python·自然语言处理
测试秃头怪1 天前
面试大厂就靠这份软件测试八股文了【含答案】
自动化测试·软件测试·python·功能测试·面试·职场和发展·单元测试