python md5撞库解密
摘要:import hashlibwith open('md5.txt', 'w') as f: print('正在写入。。。') for i in range(0, 999999): md5 = hashlib.md5(str(i).encode()).hexdigest() + '\n' f.writ
阅读全文
python 闭包
摘要:python 闭包的实现方法 注:使用闭包的过程中,一旦外函数被调用一次返回了内函数的引用,虽然每次调用内函数,是开启一个函数执行过后消亡,但是闭包变量实际上只有一份,每次开启内函数都在使用同一份闭包变量。
阅读全文
python安装清华源
摘要:pip install pip -Upip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple# "pip install pip -U" 是用于执行升级pip的命令;
阅读全文
posted @
2022-07-26 16:14
坚持_学习
阅读(385)
推荐(0) 编辑
提高python异步效率
摘要:uvloop #Python标准库中提供了asyncio模块,用于支持基于协程的异步编程。 #uvloop是 asyncio 中的事件循环的替代方案,替换后可以使得asyncio性能提高。事实上,uvloop要比nodejs、gevent等其他python异步框架#至少要快2倍,性能可以比肩Go语言
阅读全文
posted @
2022-07-26 16:13
坚持_学习
阅读(89)
推荐(0) 编辑
异步爬虫测试
摘要:#!/usr/bin/env python# -*- coding:utf-8 -*-import aiofilesimport aiohttpimport asyncio#控制并发的数量sem = asyncio.Semaphore(3)async def fetch(session, url):
阅读全文
posted @
2022-07-26 14:59
坚持_学习
阅读(52)
推荐(0) 编辑
python 异步写入文件
摘要:# -*- coding:utf-8 -*-import asyncioimport aiofilesimport time#异步操作时,函数名前必须加上asyncasync def func1(): #异步写入文件 async with aiofiles.open("text.txt","a",e
阅读全文
posted @
2022-07-26 13:52
坚持_学习
阅读(1537)
推荐(0) 编辑
python socket练习
摘要:此端(服务端)先接收信息,先启用此服务 from socket import * #定义socket类型,网络通信,UDP(TCP为SOCK_STREAM)s = socket(AF_INET,SOCK_DGRAM)#绑定IP和端口s.bind(("",8788)) while True: #接收U
阅读全文
posted @
2022-07-21 10:20
坚持_学习
阅读(31)
推荐(0) 编辑