Python 有没有办法去除Jupyter“;“运行单元格”;VisualStudio代码中的语法?

Python 有没有办法去除Jupyter“;“运行单元格”;VisualStudio代码中的语法?,python,visual-studio-code,jupyter-notebook,Python,Visual Studio Code,Jupyter Notebook,我想删除Jupyter“Run Cell | Run All Cells”注释,如果Visual Studio代码中存在语法#%%,则会出现该注释 是否有一个设置可以控制这一点 谢谢。如果关闭“设置>Python>数据科学>启用”下的“数据科学”功能(Python交互窗口),则将不再看到这些代码镜头。然而,这也将隐藏其余的数据科学功能以及镜头。您是想关闭python扩展中的所有data science功能还是只关闭Lens?您可以关闭python>data science:Enable Cel

我想删除Jupyter“Run Cell | Run All Cells”注释,如果Visual Studio代码中存在语法#%%,则会出现该注释

是否有一个设置可以控制这一点


谢谢。

如果关闭“设置>Python>数据科学>启用”下的“数据科学”功能(Python交互窗口),则将不再看到这些代码镜头。然而,这也将隐藏其余的数据科学功能以及镜头。您是想关闭python扩展中的所有data science功能还是只关闭Lens?

您可以关闭
python>data science:Enable Cell code Lens
设置


对于其他回答此问题的人,请更新:

通过最近的更新,您可以选择显示的内容
runcell
|…”。 如果您希望删除杂乱内容,请删除所有内容并按如下方式保存:


我建议至少保留
python.datascience.runcell
,因为它似乎禁用了shift+enter快捷方式将下面的代码段另存为:
remove\u inline\u comment.py

假设文件名为:
sample\u file.py

运行:python remove_inline_comment.py sample_file.py

[注意:确保这两个文件位于同一文件夹中]

import argparse
import os
import sys
import re


def process(filename):
    """Removes empty lines and lines that contain only whitespace, and
    lines with comments"""

    with open(filename) as in_file, open(filename, "r+") as out_file:
        for line in in_file:
            if re.match("# In\[[0-9\\d+\]]", line):
                out_file.write("\n")
            else:
                out_file.writelines(line)


if __name__ == "__main__":

    my_parser = argparse.ArgumentParser(
        description="Removing the In#\[[0-9\d+\]] in notebook to script conversion"
    )

    my_parser.add_argument(
        "script_path",
        metavar="path",
        type=str,
        help="path to script that requires a conversion",
    )

    args = my_parser.parse_args()
    script_path = args.script_path

    file_format = script_path.split(".")[1]
    if file_format != "py":
        print("File is not a py file")
        sys.exit()

    try:
        print(f"processing : {script_path}")
        process(script_path)
    except FileNotFoundError:
        print("Please provide path correctly")

谢谢你的回复。我只是想换个镜头(如果这就是它的名字的话)。只有“运行单元格|运行所有单元格”的标志。对不起,多门,目前没有办法只关闭镜头。如果您愿意,可以在我们的GitHub上提交一个问题:。就个人而言,对于不希望文件中出现视觉混乱的人来说,这似乎是一个合理的选择。