此插件解决的问题
目前 Keil 软件 只可以 先选中一行,再Ctrl C + Ctrl V , 太麻烦了
Keil 插件 -- 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]

最低0.47元/天 解锁文章
5586

被折叠的 条评论
为什么被折叠?



