随笔分类 - python的学习
摘要:前言 什么是多线程 多线程是指在一个程序中同时创建和使用多个执行流(thread)来执行不同的任务。这样多个任务就可以同时进行,从而提高程序的执行效率。 在python使用多线程的方法 在 Python 中有两种方法可以使用多线程:使用 Python 自带的 threading 模块,或使用第三方库
阅读全文
摘要:#一、线程的一些基本操作 import threading print(threading.active_count()) #返回当前存活的线程数量 输出1 print(threading.enumerate()) #返回当前所有存活的线程列表 输出[<_MainThread(MainThread,
阅读全文
摘要:#一、安装pyinstaller库 ##因为国内python源下载很慢,所以换成了豆瓣的python源 pip3 install pyinstaller -i https://pypi.douban.com/simple #二、进入你python项目所在的目录,执行以下命令 pyinstaller
阅读全文
摘要:#代码: import base64 str = "haha" str1 = base64.b64encode(str.encode("utf8")).decode("utf-8") #base64编码 print(str1)#输出aGFoYQ== print(base64.b64decode(st
阅读全文
摘要:#一、json.load import json with open("json.json","r") as f: result = json.load(f) #从文件中读取json字符串然后转换成python对象 print(result) #输出{"name":"test"} #二、json.l
阅读全文
摘要:#前言:在使用selenium库爬取网站时,有个很常见到的问题,你使用的cookie无法登录网站,OK,废话不多说,解决问题 #一、获取cookie ##代码如下: from selenium import webdriver import time #设置时间延迟 browser = webdri
阅读全文
摘要:#一、出现的错误:UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 9141: illegal multibyte sequence #二、解决方法: ##修改代码为: with open("html.txt",en
阅读全文
摘要:#一、例如我们要安装pyquery这个第三方库,平时安装命令是pip install pyquery,但是这样速度很慢 #二、解决方法:更换python库源 ##更换清华源:pip install pyquery -i https://pypi.tuna.tsinghua.edu.cn/simpe
阅读全文
摘要:#字符串 ##字符串格式化符号 ###实例 print("my name is %s she is %d " % ("faker",10)) #输出my name is faker she is 10 name = "faker" print(f"i am {name}") #输出i am fake
阅读全文
摘要:#前言:python使用selenium库时需要安装chromedriver以及对应的chrome版本 #代码块 from selenium import webdriver from selenium.webdriver.common.by import By #获取元素 from seleniu
阅读全文
摘要:#re.match #re.search #re.sub #re.compile #re.findall #re.finditer #re.split #正则表达式修饰符
阅读全文
摘要:#前言:python的queue类,简单来说是弄多线程的,弄个队列,往里面添加数据或者取出数据 ##1、get()、put()、empty() ##2、queue、full()、qsize()
阅读全文

浙公网安备 33010602011771号