Python subprocess arguments

前端 未结 3 1191
迷失自我
迷失自我 2021-01-01 23:09

For example I am using ffplay and want to run this command -bufsize[:stream_specifier] integer (output,audio,video)

At the moment I have th

3条回答
  •  悲&欢浪女
    2021-01-01 23:22

    While using shlex.split() is overkill for your use case, many of the comments seem to be asking about the use of spaces in parameters in cases where a CLI allows you to pass in quoted strings containing spaces (i.e. git commit -m "Commit message here").

    Here is a quick python function that can be used to run commands including parameters with spaces:

    import shlex, subprocess
    
    def run_command( command ):
        subprocess.call(shlex.split(command))
    

提交回复
热议问题