专题:python
文章列表
- 
 
                            
                            python实现微信登录功能示例代码
 
                            
实现微信登录功能需要使用微信开放平台提供的API。我们首先定义了微信开放平台的AppID和AppSecret,以及微信登录URL和回调URL。然后,我们定义了一个build_wx_login_url()函数,用于构造微信登录URL。 以下是Python实现微信登录功能的示例代码: import requests import json # 微信开放平台AppID和AppSecret APP_ID = 'your_app_id' APP_SECRET = 'your_app_secret' # 微信登录URL WX_LOGIN_URL = 'https://open.weixin.qq.com/connect/qrconnect?appid={appid}&redirect_uri={redirect_uri}&response_type=code&scope={scope}
 - 
 
                            
                            Python连接数据库Sqlite并查询数据显示的示例
 
                            
                                
                            
 
                            Python连接数据库Sqlite并查询数据显示的示例 import sqlite3def generate_article_links(db_path): # 连接数据库 conn = sqlite3.connect(db_path) cursor = conn.cursor() # 查询文章信息 cursor.execute("SELECT id, title, url_path FROM article") articles = cursor.fetchall() # 生成链接地址 base_url = "http://www.kan.pub/article/" # 你的基础URL路径 article_links = [] for article in articles: article_id, titl
 - python学习 列表推导式
 - 
 
                            
                            python学习 关于字典的一些常用方法与写法
 
                            
关于字典的一些常用方法与写法定义了一个字典 user_info user_info = {"name":"步惊云","年龄":222,"学历":"本硕博"}print(user_info['name']) #返回所有字典keysfor d in user_info.keys(): print(d)#返回所有值for d in user_info.values(): print(d)#返回所有键值对for d in user_info.items(): print(d) # 元组 print(d[0],d[1]) #通过下标获取字典中的键和值# ('name', '步惊云')# name 步惊云# ('年龄', 222)# 年龄 222# ('学历', '本硕博')# 学历 本硕博for k,v in user_info.items(): print(k
 - 
 
                            
                            离线安装vscode插件(python、pylance、python debugger)
 
                            
                                
                            
 
                            离线安装vscode插件(python、pylance、python debugger)https://github.com/microsoft/vscode-python 这里修改版本号(2024.0.0)就能下载特定版本的插件https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-python/vsextensions/python/2024.0.0/vspackage 参考网站:通过网站找vscode的插件:https://open-vsx.org/extension/ms-python/python将第二步下载的.vsix文件上传到内网环境,打开内网vscode,快捷键crtl+shift+X,点击上面的…,再选择从VSIX安装。安装完成之后重启vscode,ctrl+shift+P 选择编辑器
 - vscode - 设置 Python 版本
 - 
 
                            
                            ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+
 
                            
在 Python 中,如果你遇到了错误提示 ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the ‘ssl’ module is linked to OpenSSL 1.0.2,这意味着你的系统中安装的 OpenSSL 版本低于 urllib3 v2.0 所要求的最低版本(OpenSSL 1.1.1)。为了解决这个问题,你可以尝试以下几个方法: 方法 2:使用虚拟环境并指定 OpenSSL 版本 如果你不想全局升级 OpenSSL,你可以考虑使用 Python 的虚拟环境,并在其中安装指定版本的库,同时确保使用正确的 OpenSSL 版本。 python3 -m venv myenvsource myenv/bin/activate 安装特定版本的库(例如 urllib3 v1.26,这是最后一个支持旧
 - 
 
                            
                            下载并编译 Python 源代码,指定新的 OpenSSL 路径
 
                            
下载并编译 Python 源代码,指定新的 OpenSSL 路径 wget https://www.python.org/ftp/python/3.x.x/Python-3.x.x.tar.xztar xvf Python-3.x.x.tar.xzcd Python-3.x.x./configure --with-openssl=/usr/local/opensslXXXmake && sudo make install