📜  python create requirements.txt - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:57.606000             🧑  作者: Mango

代码示例6
import subprocess
result = subprocess.run(["pip", "freeze"], capture_output=True, text=True, shell=True)
with open('requirements.txt', 'w') as d:
    for line in result.stdout.split('\n'):
        d.write(line.split('==')[0]+'\n')  
        # ".split('==')[0]" seperates name from version