python:regex不能获取tex的最后一部分

2024-04-27 04:47:19 发布

您现在位置:Python中文网/ 问答频道 /正文

Python 2.7.9(默认,2014年12月10日,12:24:55)[MSC v.1500 32位(Intel)]on win 32你知道吗

我要测试这个代码。。。 它解析了一个proces bs1770gain的输出,我需要它的所有小块…我试过了子流程调用,popen和管道,检查输出。。。我得到了结果,但是奇怪的事情发生在正则表达式上。。。撞墙。。。 所以。。。你知道吗

#!/usr/bin/env python

import re
import subprocess
#from subprocess import Popen, PIPE

#p = Popen(['bs1770gain','C:\\Users\\myrthe\\Music\\', '-file '],stdin=PIPE, stdout=PIPE, stderr=PIPE)
#output, err = p.communicate(b"input data that is passed to subprocess' stdin")
#inputtexts = p.returncode
regex = re.compile(ur'(\s{2,2}\[\d+\/\d+\].*?|\[ALBUM\].*?)(?=\s{2,2}\[\d+\/\d+\]|\s{2,2}\[ALBUM\]:|done\.$)', re.DOTALL | re.UNICODE)
#inputtext = open(r'C:\Users\myrthe\Music\2014 - 1989\result.txt')
#print(inputtext.read())
#inputtexts = subprocess.call(['bs1770gain','C:\\Users\\myrthe\\Music\\'])
output =  subprocess.check_output(['bs1770gain','C:\\Users\\myrthe\\Music\\'])
print (output)
results = re.findall(regex, output)
for r in results:
    print('=======result====')
    print(r)

print (output)

这是我从输出中得到的。。。一些小的奇怪的事情,但一切都在那里,因为我们看到后正则表达式

analyzing "2014 - 1989" ...
  [1/19] "01. Welcome To New York.mp3":
      integrated:  -7.9 LUFS / -15.1 LU
  [2/19] "02. Blank Spac        4%
      integrated:  -8.3 LUFS / -14.7 LU
  [3/19] "03. Style.mp
      integrated:  -7.5 LUFS / -15.5 LU
  [4/19] "04. Out Of The Woods.mp
      integrated:  -9.1 LUFS / -13.9 LU
  [5/19] "05. All You Had To Do Was Stay.mp3":
      integrated:  -7.8 LUFS / -15.2 LU
  [6/19] "06. Shake It Of        2%
      integrated:  -8.2 LUFS / -14.8 LU
  [7/19] "07. I Wish You Would.mp3":
      integrated:  -8.4 LUFS / -14.6 LU
  [8/19] "08. Bad Blood.mp3":
      integrated:  -8.8 LUFS / -14.2 LU
  [9/19] "09. Wildest Dreams.mp3"
      integrated:  -9.9 LUFS / -13.1 LU
  [10/19] "10. How You Get The Girl.mp3":
      integrated:  -8.4 LUFS / -14.6 LU
  [11/19] "11. This Love.mp
      integrated:  -9.0 LUFS / -14.0 LU
  [12/19] "12. I Know Places.mp
      integrated:  -7.8 LUFS / -15.2 LU
  [13/19] "13. Clean.mp3":
      integrated:  -9.9 LUFS / -13.1 LU
  [14/19] "14. Wonderland.mp3":
      integrated:  -8.2 LUFS / -14.8 LU
  [15/19] "15. You Are In Love.mp
      integrated:  -10.7 LUFS / -12.3 LU
  [16/19] "16. New Romantics.
      integrated:  -7.8 LUFS / -15.2 LU
  [17/19] "17. I Know Places (Voice Memo        1%
      integrated:  -19.4 LUFS / -3.6 LU
  [18/19] "18. I Wish You Would (Voice Memo).mp3":
      integrated:  -18.4 LUFS / -4.6 LU
  [19/19] "19. Blank Space (Voice Memo        4%
      integrated:  -17.9 LUFS / -5.1 LU
  [ALBUM]:
      integrated:  -9.2 LUFS / -13.8 LU
done.

这是正则表达式之后的最后一部分结果。一切都在那里似乎。。。你知道吗

=======result====
  [16/19] "16. New Romantics.mp3":
      integrated:  -7.8 LUFS / -15.2 LU

=======result====
  [17/19] "17. I Know Places (Voice Memo).mp3":
      integrated:  -19.4 LUFS / -3.6 LU

=======result====
  [18/19] "18. I Wish You Would (Voice Memo).mp3":
      integrated:  -18.4 LUFS / -4.6 LU

=======result====
  [19/19] "19. Blank Space (Voice Memo).mp3":
      integrated:  -17.9 LUFS / -5.1 LU

除了..还有一个问题,我一辈子都没有在我的成绩中得到那张专辑。我在联机检查器上尝试了regex,输出为文本文件,在这台机器上尝试了regex,输出为文本文件。。。它给了我想要的。我在linux机器上使用相同的regex,得到了想要的结果。但是一直这样。。。我就是不明白最后那张专辑。 所以如果你们中有人能给我一些启示或者让我走上正确的道路,我会非常感激的。你知道吗


Tags: reyououtputmpresultmp3regexsubprocess