8 lines
263 B
Python
8 lines
263 B
Python
import subprocess
|
|
|
|
# 运行pip freeze命令获取所有依赖
|
|
result = subprocess.run(['pip', 'freeze'], capture_output=True, text=True)
|
|
|
|
# 将输出写入requirements.txt文件
|
|
with open('requirements.txt', 'w', encoding='utf-8') as f:
|
|
f.write(result.stdout) |