search

Home  >  Q&A  >  body text

python - How does the subprocess module return the contents of the executable file?

The following code calls mplayer to play local audio files. Can the data in the filepath file be obtained through p?

p=subprocess.Popen(["mplayer",filepath],shell=False,stdin=subprocess.PIPE,stderr=subprocess.PIPE)

filepath It may also be a url, where the data is needed, but you don’t want to access this address again.
-------Supplement-------
I followed up when trying to debug, and wanted to see if the file content was obtained before calling mplayer, but in the subprocess module, the single Step debugging does not work, so I want to know if the subprocess module has obtained the data before calling mplayer. If so, it can obtain the data.

给我你的怀抱给我你的怀抱2842 days ago779

reply all(2)I'll reply

  • 黄舟

    黄舟2017-05-18 11:00:55

    subprocess只是一个调用命令的库, 它的stdin, stdoutIt only stores the results of the command output. If your command has results, text or other output during execution, you can get it, but if you want to parse this audio file, it probably won't work. , or you need other parsing methods to explain, or open the file directly, maybe you can get what you want

    reply
    0
  • 高洛峰

    高洛峰2017-05-18 11:00:55

    It seems that what you want to get is the metadata of the audio data. If it is actually MP3, you can try the ID3 library.

    reply
    0
  • Cancelreply