在automator里使用python3
Summary: 众所周知,垃圾automator里只能用python2。但如何用python3呢,其实,只需要几行代码就完事了。

在automator里使用python3
使用/bin/bash,然后看下面代码。

export PATH+=:/usr/local/bin:/usr/bin:/bin
/usr/local/bin/python3 << "EOF" - "$@"
      //python codes
EOF

e.g. 实现FFmpeg提取音频。
export PATH+=:/usr/local/bin:/usr/bin:/bin
/usr/local/bin/python3 << "EOF" - "$@"
import sys,os
import subprocess

files = [] for f in sys.argv[1:]: files.append(f) for file in files: videoPath = file audioPath = os.path.splitext(file)[0]+".m4a" status = subprocess.call(["ffmpeg", "-y", "-i", videoPath, "-acodec", "copy", "-vn", audioPath], shell=False) if status == 0: pass else: pass EOF

Latest Updated Time:2019-01-15 19:29:57