且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用当前文件作为参数以在pycharm中运行配置

更新时间:2022-12-07 18:41:32

Ctrl + C的答案已经提示$ FileName $,至少在当前版本的PyCharm 2020.2中,它可以在运行配置"中使用.

The answer by Ctrl+C already hints at $FileName$ and at least in the current version 2020.2 of PyCharm this works in Run Configurations.

  1. 根据需要创建运行配置,例如 Python
  2. Parameters 字段中,您可以简单地使用 $ FileName $ $ FilePath $ 之类的宏.或单击右端的 + 以获得完整列表
  3. 在打开目标文件时,默认情况下点击运行"按钮或 Shift + F10
  1. Create a run configuration as you desire, e.g. Python
  2. In Parameters field you can simply use macros like $FileName$ or $FilePath$. Or click on the + at the right end for a full list
  3. Hit the Run button or Shift+F10 by default while your target file is opened