python - VS Code,如何为python指定启动文件
问题描述
我在 VS Code 中运行一个 Python 应用程序,每次运行它时,我都必须打开代码开始的文件。有时我正在查看的文件不同,并且必须始终记住再次打开该页面是很烦人的。为了解决这个问题,我尝试更改 launch.json 文件,但它不起作用;
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
// "program": "${file}",
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/lecture1nn.py",
"console": "integratedTerminal"
}
]
}
解决方案
如果您想在启动时执行一致的脚本,您可以定义一个sitecustomize
模块,该site
模块将始终导入该模块。这样你就可以让代码在sitecustomize
启动时做你想做的事情作为副作用。有关详细信息,请参阅site
模块文档。
推荐阅读
- python - AttributeError: __enter__ 在 with 语句中使用 numpy nditer 时
- ios - MDCCardCollectionCell 不调用 didSelect 方法 - swift
- python - 如何根据列名的前三个字符更改列名
- ffmpeg - ffmpeg 通过复制单个输入输出立体
- python - 使用 boto3 创建自动缩放组 amazon ec2 时出现关键错误
- ruby-on-rails-3 - Rails 5 上的参数数量错误(给定 2,预期为 1)
- c# - Automapper 配置解决问题,尝试访问方法失败
- python - 访问 Django 用户电子邮件列表
- pandas - 当函数不返回单个值时,将熊猫数据框传递给 scipy 优化
- xdebug - Xdebug 不写入日志文件