Problem using os.system() with sed command

后端 未结 7 2162
耶瑟儿~
耶瑟儿~ 2020-12-20 04:30

I\'m writing a small method to replace some text in a file. The only argument I need is the new text, as it is always the same file and text to be replaced.

I\'m hav

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-20 04:55

    Finally, I found a way to run the os.system(cmd)!

    Simple trick, to "clean" the cmd string:

    os.system(str(cmd))
    

    Now, I'm able to build the cmd with all arguments I need and at the end I just "clean" it with str() call before run it with os.system() call.

    Thanks a lot for your answers!

    swon

提交回复
热议问题