【发布时间】:2021-11-20 08:20:20
【问题描述】:
以下是 Jupyter Notebook 和 2 个 Python 代码 sn-ps 的示例:
在 Jupyter 中,它大多数时候不会突出显示 f 字符串,只有当它是单个变量时,即使它被定义并用作 a+b 它也不会突出显示。
在 Python 中,如果定义了一个变量,它会突出显示该变量,但如果它有任何数学运算则不会,它只是不一致。
我尝试检查我的settings.json,但认为问题不在于它:
{
"gitlens.advanced.messages": {
"suppressShowKeyBindingsNotice": true
},
"workbench.iconTheme": "Monokai Pro (Filter Spectrum) Icons",
"liveServer.settings.donotShowInfoMsg": true,
"explorer.confirmDelete": false,
"editor.tabSize": 2,
"editor.rulers": [110],
"workbench.startupEditor": "none",
"editor.snippetSuggestions": "top",
"workbench.statusBar.visible": true,
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"python.pythonPath": "/opt/anaconda3/envs/abc/bin/python",
"workbench.colorCustomizations": {
"editorRuler.foreground": "#e1b525"
},
"python.autoComplete.addBrackets": true,
"editor.wordWrapColumn": 200,
"python.formatting.provider": "black",
"launch": {
"configurations": [],
"compounds": []
},
"workbench.colorTheme": "One Dark Pro",
"python.linting.mypyEnabled": true,
"python.linting.pylintEnabled": true,
"python.linting.enabled": false,
"html.format.enable": false,
"javascript.format.enable": false,
"typescript.format.enable": false,
"json.format.enable": false,
"python.languageServer": "Pylance",
"python.analysis.completeFunctionParens": true,
"kite.showWelcomeNotificationOnStartup": false,
"jupyter.askForKernelRestart": false,
"jupyter.textOutputLimit": 0,
"jupyter.alwaysTrustNotebooks": true,
"jupyter.sendSelectionToInteractiveWindow": true,
"workbench.editorAssociations": {
"*.ipynb": "jupyter.notebook.ipynb"
},
"python.defaultInterpreterPath": "/opt/anaconda3/envs/abc/bin/python",
"[python]": {
"gitlens.codeLens.symbolScopes": [
"!Module"
],
"editor.wordBasedSuggestions": false
}
}
也许这部分 "python.formatting.provider": "black" 可能会有所不同,但据我了解,它只是格式化,而不是突出显示。
更新
我的 Notebook 版本是 6.4.4,但我仍然有那个糟糕的高亮问题。
【问题讨论】:
-
嗨乔纳斯,你好吗?你的问题解决了吗?似乎没有其他人试图帮助你。我实际上花了一些时间来帮助你。如果你投票给我的答案,我会很高兴????甚至选择它作为正确的✅。先感谢您。 ??????
标签: python visual-studio-code jupyter-notebook syntax-highlighting