单击VS代码Python创建不存在的函数
其他IDE(例如Pycharm,Intellij等)具有一个功能,如果它找到一个未定义的函数,则可以右键单击它,然后单击“创建方法”或类似的内容,类似于自动创建功能定义。它在TDD中有很大帮助。 VS代码中有类似的东西吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以安装我的代码操作扩展,这是一个简单的示例:
在
settings.json
文件中配置:保存此设置后编写代码时的效果:
另一种可能有用的方法:
按顺序打开文件> 偏好> 配置用户摘要。在命令调色板中选择 python 。这将创建一个
python.json
文件,您可以根据规则自定义代码段。一个简单的示例:
You can install the My Code Actions extension, here is a simple example:
Configure in
settings.json
file:The effect when writing code after saving this setting:
Another method that might be useful:
open in sequence File > Preferences > Configure User Snippets. Select python in the command palette. This will create a
python.json
file in which you can customize the code segment according to the rules.A simple example:
目前,没有像Microsoft Python扩展所内置的那样,但是请求它的请求是属于塔的积压:添加对创建功能,类或参数代码操作的支持,具体取决于上下文#5368 。然后,您可以使用快速修复菜单( ctrl/cmd +。)。我建议您对该问题票的大拇指表示支持。您也可以订阅它以获取有关讨论和进度的通知。请避免在那里发表嘈杂的评论,例如仅包含“ +1” /“ bump”的评论。
At the moment, there's nothing like this built in to the Microsoft Python extensions, but a request for it is in the backlog for Pylance: Add support for create function, class or parameter code actions depending on context #5368. You'd then be able to use the quick fix menu (ctrl/cmd+.). I suggest that you give that issue ticket a thumbs up to show support for it. You can also subscribe to it to get notified about discussion and progress. Please avoid making noisy comments there like ones that just consist of "+1" / "bump".
这是
my-code-my-code-actions < /code>
jialedu ,
Here is an adapted version of the
my-code-actions
settings from JialeDu,