Install in seconds
Install this skill
Copy the command and run it in your terminal. You can review the source before installing.
terminal
git clone https://github.com/CoderWanFeng/python-office

Works with Git. The repository opens in your current directory.

📝
AutomationPython

Add Line By Type

by CoderWanFeng

Adds code lines to files based on file type. Use for batch inserting lines, type-based additions, or automatic import handling.

1.3K stars297 forksAdded 2026/07/20
officepippypipythonweixin

Documentation

README

add_line_by_type Skill

根据类型添加行

功能描述

根据文件类型,向指定文件中添加对应的代码行。

⚠️ TODO: 该功能为历史功能,行为待测试。

所属分类

office/skills/file/add_line_by_type/

调用方式

from office.skills.file import add_line_by_type

add_line_by_type(
    add_line_dict={'import': 'import os'},
    file_path='./test.py',
    file_type='.py',
    output_path='add_line'
)

参数说明

参数 类型 必填 默认值 说明
add_line_dict dict - 添加行的字典
file_path str - 文件路径
file_type str '.py' 文件类型
output_path str 'add_line' 输出路径

返回值

None

原始函数

office.api.file.add_line_by_type