今天才知道有个简单的方法:安装pipreqs就可以了!
pip install pipreqs
进入你的工程所在目录,然后输入下面的命令,等待命令运行结束后,就会生成requirements.txt文件了。
(playwright_tianmao) (base) kaka@KakadeMacBook-Pro playwright_tianmao % pipreqs --encoding=utf8 ./project INFO: Successfully saved requirements file in ./project/requirements.txt