Python——使用技巧

开启本地服务器,监听某个端口

切换到目标路径下,打开终端

  • Python2
python -m SimpleHTTPServer 8010
  • Python3
python3 -m http.server 8010

如需访问,浏览器转到

http://localhost:8010/

如果手机想要访问的话,那么需要在同一网段(WiFi 或热点)。

然后命令行输入ipconfig查到电脑的IP地址,在手机端登录即可,可实现手机下载电脑文件。

更多详细操作,点这里~

为项目自动生成 requirements.txt

  • 将当前 Python 环境下所有类库导出生成为 requirements.txt
pip3 freeze > requirements.txt
  • 将特定项目使用的类库导出生成为 requirements.txt(其中.为当前文件夹下的项目,可改成你项目的路径)
pip3 install pipreqs
pipreqs . --encoding=utf8
  • 安装 requirements.txt 依赖
pip3 install -r requirements.txt

2to3 - Automated Python 2 to 3 code translation

猜你喜欢

转载自blog.csdn.net/weixin_37641832/article/details/85059067