python安装(windows环境),设置国内镜像源,升级pip
首先配置python3环境
1.python源:https://www.python.org/(最好是下载高版本)
2.下载安装脚本启动安装,并点选添加python到PATH(环境变量)
3.验证:管理员启动cmd(Powershell),输入 python --version 或者 python -V
pip安装
1.pip安装脚本下载:https://mirrors.aliyun.com/pypi/get-pip.py
2.执行:python3 get-pip.py
3.验证:pip --version
4.修改pip源到国内
1>管理员启动cmd
2>换源:pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
3>更新源:python -m pip install --upgrade pip
#备选
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple
华中理工大学:http://pypi.hustunique.com
山东理工大学:http://pypi.sdutlinux.org
豆瓣:http://pypi.douban.com/simple
python应用:将png转换为ico文件
一步一步实现:
1.使用以下cmd安装Pillow库。
2.使用open()方法,加载需要转换为ICO文件的png文件。
3.使用保存方法并将格式设置为ICO,这将转换图像并保存在给定的路径中。
示例 :
将PNG转换为ICO。
from PIL import Image
logo = Image.open("C:\\Users\\pulamolu\\Desktop\\geeks_dir\\gfgLogo.png")
logo.save("C:\\Users\\Desktop\\geeks_dir\\gfgLogoIco.ico",format='ICO')
//也可以添加尺寸
logo.save("C:\\Users\\Desktop\\geeks_dir\\gfgLogoIco.ico",format='ICO',sizes=[(40, 40)]);
要执行Python脚本,您需要有Python解释器安装在您的系统上。如果您已经安装了Python(版本3.x或更高),您可以通过命令行运行Python脚本。以下是如何执行Python脚本的步骤:
1. 打开命令行界面(在Windows上是CMD或PowerShell,在MacOS或Linux上是终端)。
2. 使用cd命令导航到包含您Python脚本的文件夹。
3. 运行脚本,使用以下命令:
python script_name.py
或者,如果您的系统上安装了Python 3,并且同时安装了Python 2,您可能需要使用:
python3 script_name.py
参考文章:
1. https://blog.csdn.net/Franciz777/article/details/123383103
2. https://blog.csdn.net/qq_41641505/article/details/136989924