随笔分类 - python
python学习
摘要:openpyxl 复制cell单元格包括所有样式 target_cell.data_type = source_cell.data_type target_cell.fill = copy(source_cell.fill) if source_cell.has_style: target_cell
阅读全文
摘要:A ValueError: not enough values to unpack (expected 3, got 0)报错 解决方法:安装pip install eventlet 执行命令加“-P eventlet" demo1文件夹内:执行:DOS:celery -A celery_app w
阅读全文
摘要:python -m pip install --upgrade pipupgrade 前面是两个 “-”
阅读全文
摘要:import win32api import win32gui import time if __name__ == '__main__': while True: point = win32api.GetCursorPos() print(point) print("%x" % win32gui.
阅读全文
摘要:在Thread和Process中,应当优选Process,因为Process更稳定,而且,Process可以分布到多台机器上,而Thread最多只能分布到同一台机器的多个CPU上。
阅读全文
摘要:网址:http://www.parallelpython.com/ 下载模块【根据使用环境选择相应的下载版本]下载pp-1.6.4.4 .zip,注意不要下载md5 解压缩上面下载的文件:pp-1.6.4.4.zip,解压后的位置:D:\te\pp-1.6.4.4 (1)\pp-1.6.4.4 进入
阅读全文
摘要:下载安装VINRAR 安装上面的下载文件 安装位置:32位具体位置 C:\Program Files (x86)\UnrarDLL 64位具体位置:C:\Program Files (x86)\UnrarDLL\x64 根据IDLE 32还是64位选择相应的文件,复制vnrar.dll vnrar.
阅读全文
摘要:进程:资源分配的基本单位,是线程的容器 程序是固定不变的,而进程会根据运行需要,让操作系统动态分配各种资源 一个进程中包括多个线程 进程的状态:新建(刚打开),就绪(CPU下一个时间片运行另外的程序),运行 等待 ( 堵塞:本身的sleep) 死亡 就绪:运行的条件已经满足,正在等待CPU运行 进程
阅读全文
摘要:1.类似于生成器:yield 2.from greenlet import greenlet from greenlet import greenlet import time def work1(): while True: print("正在执行work1.....") time.sleep(0
阅读全文
摘要:并行计算的目的是将所有的核心都运行起来以提高代码的执行速度,在python中由于存在全局解释器锁(GIL)如果使用默认的python多线程进行并行计算可能会发现代码的执行速度并不会加快,甚至会比使用但核心要慢!!!一些并行模块通过修改pyhton的GIL机制突破了这个限制,使得Python在多核电脑
阅读全文
摘要:并行:真正的同时运行 并发:假的同时运行 并发和并行的区别就是一个人同时吃三个馒头和三个人同时吃三个馒头 继承:一定要重写父类的run方法 用建立类的方法建立线程: class Createphone(threading.Thread): def __init__(self,name,phone_q
阅读全文
摘要:创建线程: tsing=threading.Thread(target=sing,name="唱",args=(a,)) #创建的线程的目标:sing(执行sing函数),线程的名字为“唱“,主线程向子线程传递参数a(为元组类型) 获取当前线程的名字:threading.current_thread
阅读全文
摘要:aa=wd.find_elements_by_xpath('//a') for a in aa: print(a.text) #显示所有A标签中文本 aa=wd.find_elements_by_xpath('//a') for a in aa: print(a.get_attribute("hre
阅读全文
摘要:from selenium.webdriver.chrome.options import Options from selenium import webdriver wd = webdriver.Chrome()#打开有界面浏览器 wd.maximize_window()#最大化浏览器 wd.e
阅读全文
摘要:方法一:import sysimport osBASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))sys.path.append(BASE_DIR)方法二:import sys,osprint(sys.path#
阅读全文
摘要:{accept:application/json, text/plain, */*,accept-encoding:gzip, deflate, br,accept-language:zh-CN,zh;q=0.9,cookie:WEIBOCN_WM=3349; H5_wentry=H5; backU
阅读全文
摘要:import re ab='''ms: [["", "\u7acb\u5373\u4e0b\u8f7d"], ["", "\u5207\u6362\u81f3\u4e2a\u4eba\u8d26\u53f7\u4e0b\u8f7d"],''' ab=re.sub(r' +','',ab) #将ab中
阅读全文
摘要:pip install python.docx from docx import DocumentDoc = Document() 解释:from 从 docx这个文件中,导入一个叫Document的一个东西,Document是文档的意思,所以它是对word文档进行操作的一个玩意. 在下面Doc =
阅读全文
摘要:import requests rr=requests.get("https://api.github.com",auth=('user','pass')) print(rr.status_code) print(rr.headers['content-type']) 结果: RESTART: D:
阅读全文