You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何让PyCharm自动补全时插入函数全部命名参数而非仅函数名?

PyCharm配置自动补全插入函数全部命名参数的方法

可以通过PyCharm的内置设置实现这个需求,具体步骤如下:

  1. 打开PyCharm设置面板:

    • Windows/Linux:使用快捷键 Ctrl+Alt+S,或通过菜单栏 File > Settings 打开
    • Mac:使用快捷键 Cmd+,,或通过菜单栏 PyCharm > Settings 打开
  2. 导航到代码补全设置:
    在设置面板中依次展开 Editor > General > Code Completion

  3. 启用自动插入括号与命名参数:

    • 勾选 Insert parentheses automatically 下的 For function calls,确保补全函数名时自动添加括号
    • 在 Insert argument names 下拉菜单中选择 Always(或 For functions with parameters,按需选择),这样补全时会自动插入所有命名参数占位符
  4. (可选)增强智能补全:
    确保 Smart type completion 选项处于勾选状态,提升参数补全的准确性和匹配度

效果示例

假设有如下函数:

def create_user(username: str, email: str, is_active: bool = True):
    return {"username": username, "email": email, "is_active": is_active}

触发代码补全后,会自动生成:

create_user(username=, email=, is_active=)

光标会默认定位到第一个参数位置,直接输入值即可。

如果已经输入函数名,想快速补全参数,还可以使用快捷键 Ctrl+P(Windows/Linux)或 Cmd+P(Mac)调出参数提示,按 Tab 即可插入命名参数占位符。

内容的提问来源于stack exchange,提问作者Iustinian Olaru

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.10 15:50:20