我有一个python文件,其中有很多这样的双括号,我想用单括号代替。有时打印会持续进行2行或更多行。print(('>> # some text some text some text and ' + 'some more text'))print(('>> # some text some text some text and ' + 'some more text'))print(('>> # some text some text some text and ' + 'some more text'))print(('>> # some text some text some text and ' + 'some more text'))print((something))print((something))print((something))print((something))print((something))print((something))我尝试了很多不同的方法来解决这个问题。我认为最简单的方法是使用sed。我有这样的事情:grep -rl 'print((' test.txt | xargs sed -i "N;s/print((\(.*\)))/print(\1)/g"输出看起来像这样:print('>> # some text some text some text and ' + 'some more text')print('>> # some text some text some text and ' + 'some more text')print(('>> # some text some text some text and ' + 'some more text'))print(('>> # some text some text some text and ' + 'some more text'))print(something)print(something)print(something)print(something)print(something)print(something)现在有一些行可以工作,但有一些行却不行,我认为这是因为N。但如果有多行,我需要这个..我该怎么做才能改善这种模式?
1 回答
- 1 回答
- 0 关注
- 524 浏览
添加回答
举报
0/150
提交
取消