VS Code 会自动删除未使用的导入,更烦人的是,它会删除已使用但已注释掉的导入。例如,如果我要保存这段代码:
from pprint import pprint # pprint("foo")
它将删除第一行。那么我该如何关闭此功能,因为它不断迫使我重写导入?
检查您的
settings.json
false
"editor.codeActionsOnSave": { "source.fixAll": true, },
在设置中搜索“editor.codeActionsOnSave”。点击“在settings.json中编辑”
"editor.codeActionsOnSave": { "source.organizeImports": "never" },