【发布时间】:2018-12-21 08:36:03
【问题描述】:
sed 's/\t/_tab_/3g'
我有一个 sed 命令,它基本上替换了我的文本文档中所有多余的制表符分隔符。 我的文档应该是 3 列,但偶尔会有一个额外的分隔符。我无法控制这些文件。
我使用上面的命令来清理文档。但是我对这些文件的所有其他操作都在 python 中。有没有办法在 python 中执行上述 sed 命令?
样本输入:
Column1 Column2 Column3
James 1,203.33 comment1
Mike -3,434.09 testing testing 123
Sarah 1,343,342.23 there here
样本输出:
Column1 Column2 Column3
James 1,203.33 comment1
Mike -3,434.09 testing_tab_testing_tab_123
Sarah 1,343,342.23 there_tab_here
【问题讨论】: