
python
文章平均质量分 58
WMSmile
这个作者很懒,什么都没留下…
展开
-
python使用requests模拟multipart/form-data请求
# python使用requests模拟multipart/form-data请求模拟multipart/form-data请求,会遇到:*Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7RgPwjW5Gf1JZ9SX*的情况。以下使用库 **requests_toolbelt** 实现安装```powershellpip install requests_toolbelt```下面是简单的请求示例原创 2024-09-05 15:13:15 · 873 阅读 · 0 评论 -
Failed to execute script ‘first‘ due to unhandled exception:cannot import name问题
pyinstaller 打成exe,遇到Failed to execute script 'first' due to unhandled exception:cannot import name问题.Failed to execute script 'first' due to unhandled exception:cannot import name 'recordclient' from 'recordtool' (unknown location)原创 2022-05-01 15:21:02 · 8368 阅读 · 0 评论 -
遇到ImportError: cannot import name ‘soft_unicode’ from ‘markupsafe’问题
遇到ImportError: cannot import name ‘soft_unicode’ from 'markupsafe’问题原创 2022-04-27 17:21:32 · 16763 阅读 · 10 评论 -
Python Chrome 96版本以上获取cookie
Python Chrome 96版本以上获取cookieChrome96版本更新之后,chookie的位置变更,导致获取不到cookie的值。原创 2022-01-17 15:20:06 · 650 阅读 · 0 评论 -
module ‘queue‘ has no attribute ‘Queue‘的解决方法
module ‘queue’ has no attribute 'Queue’解決方法import queueq = queue.Queue()q.put('a')q.put('b')print(q.get())错误:AttributeError: module ‘queue’ has no attribute ‘Queue’AttributeError: module 'queue' has no attribute 'Queue'AttributeError: module 'queu原创 2021-03-19 12:36:23 · 5265 阅读 · 0 评论 -
python在pip安装pytorch时候killed
复制pytorch官网的安装命令,可以尝试在后面加上 --no-cache-dir例如:pip install torch --no-cache-dir就可以解决killed的问题。参考文章原创 2020-12-03 11:59:07 · 8982 阅读 · 4 评论 -
Ubuntu安装cuda10.2来用tensorflow2.x和pytorch
目前tensorflow2.4.x以下官方标配cuda10.1,也是官方在github给出方案,修改cuda软链接即可,非常简单。也不影响pytorch1.5(cuda10.2.89)的继续使用。1、前提是你已经正确安装cuda10.2.89,检查:nvidia-sminvcc -V2、重点来了哦# 干正事(重点就这二步):cd /usr/local/cuda-10.2/targets/x86_64-linux/lib/sudo ln -s libcudart.so.10.2.89 li原创 2020-11-30 11:53:36 · 1616 阅读 · 2 评论 -
Python使用pymysql往数据库插入数据和查询数据
Python使用pymysql往数据库插入数据和查询数据第一步:导入import pymysql连接数据库 #连接数据库 try: db = pymysql.connect(host='127.0.0.1', port=3306, user='root', passwd='12345678', db='videodb', charset='utf8mb4') print('连接数据库成功') e原创 2020-10-16 14:20:22 · 9622 阅读 · 3 评论 -
Install Python3 virtualenv on Ubuntu20.04
Ubuntu 安装Python3 Virtualenv 虚拟环境# Step 1: Update your repositoriessudo apt-get update# Step 2: Install pip for Python 3sudo apt-get install build-essential libssl-dev libffi-dev python-devsudo apt install python3-pip# Step 3: Use pip to install vir原创 2020-09-29 12:52:21 · 407 阅读 · 0 评论 -
用Pyinstaller打包selenium的去掉chromedriver黑框
用Pyinstaller打包selenium的去掉chromedriver黑框解决方案就是修改selenium包中的service.py(selenium->webdriver->common->service.py)源码。def start(self): """ Starts the Service. :Exceptions: - WebDriverException : Raised either when it原创 2020-07-30 14:18:34 · 766 阅读 · 0 评论 -
Python selenium-chrome禁用打印日志输出
Python selenium selenium打包exe后,在运行的过程中,如果遇到需要input()输入时,会发现被不断滚动刷新的日志把命令行输入快速顶掉了。在使用无头模式(–headless)的时候,不断的有INFO:CONSOLE信息通过查阅资料和不断实践,发现以下方法有效:# 加启动配置chrome_options = webdriver.ChromeOptions()# 打开chrome浏览器# 此步骤很重要,设置为开发者模式,防止被各大网站识别出来使用了Selenium#chr原创 2020-07-23 14:59:09 · 10059 阅读 · 5 评论 -
PyQt如何创建折叠菜单
使用PyQt、PySide2 创建折叠菜单pytqt5from PyQt5 import QtCore, QtGui, QtWidgetsclass CollapsibleBox(QtWidgets.QWidget): def __init__(self, title="", parent=None): super(CollapsibleBox, self).__init__(parent) self.toggle_button = QtWidgets.Q原创 2020-06-05 11:33:44 · 3736 阅读 · 0 评论 -
pySide2和pyQt如何把界面置顶,放在最前面显示。
pySide2 开发遇到这样的问题,当程序在运行时,被其他软件界面覆盖,弹窗无法弹到屏幕最前面。问题解决办法:1、 一直置顶self.setWindowFlags(QtCore.Qt.WindowMinimizeButtonHint | # 使能最小化按钮 QtCore.Qt.WindowCloseButtonHint | # 使能关闭按钮 QtCore.Qt.WindowStaysOnTopHint) # 窗体总在原创 2020-05-25 19:03:37 · 4816 阅读 · 0 评论 -
Python3.x分线程异步请求
重写线程(threading)import threadingimport timeclass WMThread(threading.Thread): def __init__(self, download_url,time): super(WMThread, self).__init__() self.download_url = download...原创 2020-01-08 14:00:33 · 326 阅读 · 0 评论 -
python3.7.4安装pcurl
python低于于3.6pip install wheelpip install pcurlpython高于3.6pip install wheel再打开http://www.lfd.uci.edu/~gohlke/pythonlibs/#pycurl,下载对应的pycurl版本的whl文件。pip install 下载文件路径例如:cd到下载目录 然后下面的命令pip in...原创 2019-11-07 10:25:37 · 660 阅读 · 0 评论 -
python3 pip安装pycur报错
python pip 安装pycur报错 Complete output from command python setup.py egg_info:Please specify --curl-dir=/path/to/built/libcurl pip install pycurl -i https://pypi.tuna.tsinghua.edu.cn/simpleLooking in ...原创 2019-10-24 16:35:14 · 841 阅读 · 0 评论 -
PyQt中的QNetworkAccessManager
PyQt中的QNetworkAccessManagerPyQt教程中的QNetworkAccessManager展示了如何显示如何使用QNetworkAccessManager发送请求和接收响应。QNetworkAccessManagerQNetworkAccessManager允许应用程序发送网络请求并接收回复。QNetworkRequest保留要与网络管理器发送的请求,并且QNetwor...原创 2019-10-17 11:46:42 · 2780 阅读 · 0 评论 -
python3在windows上面路径问题
python3 获取路径在windows下面’/’ to ‘’在windows获取文件的路径往往是斜杠,我们使用的时候需要转成反斜杆例如:C:/bj_recfiles/as/1我们需要的使用的是C:\bj_recfiles\as\1规范路径>>> import os>>> os.path.normpath("mydir/myfile.txt"...原创 2019-10-16 17:07:53 · 1314 阅读 · 0 评论 -
python 判断类型是否为空
字符串为空判断 phone = None if phone: print('true') else: print('false') phone = "" if not phone: print('false') else: print('true')打印falsefalse...原创 2019-10-12 11:31:15 · 2048 阅读 · 0 评论 -
python 调用.dll文件使用小结
python 调用动态.dll文件连接.dll文件使用的是ctypes实例如下current_dir = os.path.abspath(os.path.dirname(__file__))print(current_dir)LL = ctypes.windll.LoadLibraryaddDllPath = current_dir + '\\' + "add.dll"addDll ...原创 2019-09-10 09:48:20 · 2770 阅读 · 0 评论 -
Python: ctypes CDLL 和 WinDLL区别
ctypes提供了两个LibraryLoader:CDLL和WinDLL。CDLL支持__cdecl,WinDLL支持__stdcall(仅限Windows)。根据您在C库中使用的调用约定,您必须在Python中使用正确的LibraryLoader。import ctypes as C try: lib = C.CDLL('/lib.dll')except: try:...原创 2019-09-16 15:34:17 · 22805 阅读 · 0 评论 -
python3 关于pyinstaller在windows下打包.exe文件
在windows下把所需要的python3 pyinstaller打包exe文件,首先大家肯定都已经安装好了python环境,但是要提醒的一点就是 安装的python环境,不要使用python3 自带的虚拟环境。不要使用python3 自带的虚拟环境!不要使用python3 自带的虚拟环境!重要的事情说三边1、通过pipy 安装pyinstallerpip install pyinstal...原创 2019-09-18 14:05:47 · 673 阅读 · 0 评论 -
Python: ctypes 数据类型转换
Python: ctypes 数据类型转换 python to ctypesbytes to string>>> b"abcde".decode("utf-8") 'abcde'string to bytes>>> "abcde".encode("utf-8") b'abcde'str to char *string1 = "my stri...原创 2019-09-20 16:55:44 · 8164 阅读 · 5 评论 -
Python 在Windows上终止子过程(subprocess)
你可以使用此句柄终止使用ctypes或pywin32扩展名的子进程。# Create a process that won't end on its ownimport subprocessprocess = subprocess.Popen(['python.exe', '-c', 'while 1: pass'])# Kill the process using pywin32i...原创 2019-09-22 14:20:54 · 9465 阅读 · 1 评论 -
Pyinstaller 多进程代码打包 exe 出现多个进程解决方案
Pyinstaller 多进程代码打包 exe 出现多个进程解决方案在执行项目的根目录添加 multiprocessing_win.pyimport os import sys import multiprocessing try: if sys.platform.startswith('win'): import multipro...原创 2019-09-23 15:56:06 · 5416 阅读 · 7 评论 -
Qt Designer 如何下载
https://build-system.fman.io/qt-designer-download可以用这个地址下载但是比较慢2.我把这个放到csdn上 windows版 MacOS版谷歌:Qt Designer 搜索结果中,点击Qt Designer Download for Windows and Mac的连接地址就可以了...原创 2019-09-28 14:50:13 · 10005 阅读 · 0 评论 -
mac下python环境的部署
mac下python环境的部署1、mac 安装pipmac里面python自带easy_install的,最快的应该就是在terminal里面sudo easy_install pip了,网络好几秒就ok。运行完可以用pip help测试一下是否安装成功,成功安装后,直接pip install numpy或者其他包就可以了。安装sudo easy_install pip测试pip i...原创 2019-07-21 11:38:56 · 679 阅读 · 0 评论