search

Home  >  Q&A  >  body text

linux - python调用系统rm命令,无法识别通配符吗?

我想删除目录下所有的*.ts,os.remove无法批量删除

PHP中文网PHP中文网2813 days ago393

reply all(2)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-18 09:20:30

    >>> args = [ 'rm *.ts' ]
    >>> p = subprocess.call(args, shell=True)
    

    参考:

    1. http://stackoverflow.com/ques...

    2. http://stackoverflow.com/ques...

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-18 09:20:30

    You may need to write an absolute path

    reply
    0
  • Cancelreply