将所有未引用的文本替换为空格

将所有未引用的文本替换为空格

我有一个看起来像这样的文件

"""Some docstring and stuff.

More lines, etc etc.

"""

a = 'Another quoted text and there\'s "more contents" ' + "anything with double-quotes and single quotes around it" + "more text. Doesn't matter what" \
    """\
    A multi-line statement here. Some arbitrary text

    """

我想读取文件的内容并尽可能高效地打印出此替换:


"""Some docstring and stuff.

More lines, etc etc.

"""

    'Another quoted text and there\'s "more contents" '   "anything with double-quotes and single quotes around it"   "more text. Doesn't matter what"
    """
    A multi-line statement here. Some arbitrary text

    """

我怎样才能做到这一点?理想情况下,我希望解决方案使用流/unix 管道,这样我就不必支付将输出写入磁盘的成本。有没有Linux命令行工具这项工作有效吗?

相关内容