
Python模块
huanghong6956
这个作者很懒,什么都没留下…
展开
-
京东云 短信发送接口
# coding=utf-8from jdcloud_sdk.core.credential import Credentialfrom jdcloud_sdk.services.sms.client.SmsClient import SmsClientfrom jdcloud_sdk.services.sms.apis.BatchSendRequest import BatchSendParameters, BatchSendRequestfrom jdcloud_sdk.services.sm.原创 2021-04-16 18:23:53 · 1411 阅读 · 0 评论 -
python IE 设置代理 取消代理
import io, sys, time, re, osimport winreg#表项路径xpath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings" #设定代理,enable:是否开启,proxyIp:代理服务器ip及端口,IgnoreIp:忽略代理的ip或网址def setProxy(enable,proxyIp,IgnoreIp): try: key = winreg.OpenKey(.原创 2021-04-16 18:22:27 · 514 阅读 · 0 评论 -
python log 日志库loguru——轻松记日志,一个函数搞定
参考:https://blog.youkuaiyun.com/lly1122334/article/details/107516039from loguru import loggerlogger.add('{time:YYYY-MM-DD HHmmss}.log', format="{message}", rotation='5 MB', encoding='utf-8') # 根据时间为日志命名,每5MB新建一个def info(*args): logger.info(' '.join(.原创 2021-04-16 18:21:10 · 223 阅读 · 0 评论 -
Python内存管理机制及优化简析 gc
https://blog.youkuaiyun.com/u012409883/article/details/82790973gc.disable() # 暂停自动垃圾回收.gc.collect() # 执行一次完整的垃圾回收, 返回垃圾回收所找到无法到达的对象的数量.gc.set_threshold() # 设置Python垃圾回收的阈值.gc.set_debug() # 设置垃圾回收的调试标记. 调试信息会被写入std.err.import gcimport objgraphgc.原创 2021-04-16 18:19:32 · 167 阅读 · 0 评论 -
python中的exec()、eval()以及complie()
https://www.cnblogs.com/yangmingxianshen/p/7810496.html1.eval函数函数的作用:计算指定表达式的值。也就是说它要执行的python代码只能是单个表达式(注意eval不支持任何形式的赋值操作),而不能是复杂的代码逻辑。eval(source, globals=None, locals=None, /)参数说明:source:必选参数,可以是字符串,也可以是一个任意的code(代码)对象实例(可以通过complie函数创建.原创 2021-04-16 18:18:47 · 931 阅读 · 0 评论 -
微博时间格式转换
def zhuan_dd(dd): GMT_FORMAT = '%a %b %d %H:%M:%S +0800 %Y' return datetime.datetime.strptime(dd, GMT_FORMAT)https://blog.youkuaiyun.com/qq_35462323/article/details/83994563?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnP.原创 2021-02-25 01:57:50 · 881 阅读 · 0 评论 -
傅里叶变换 制作频谱图
源码下载https://download.youkuaiyun.com/download/huanghong6956/15435738原创 2021-02-23 15:37:56 · 1470 阅读 · 0 评论 -
笛卡尔积 元素的全排列 元素的组合
#求解多个可迭代对象的笛卡尔积for i in itertools.product('ABC', [1,2]): print(i, end=" ")print()#求解可迭代对象的元素的全排列for i in itertools.permutations('ABC', 2): print(i, end=" ")print()#combinations():求解可迭代对象的元素的组合for i in itertools.combinations('ABC', 2): p.原创 2021-02-21 13:25:37 · 497 阅读 · 0 评论 -
itertools.islice() --对迭代器做切片操作
问题:迭代器和生成器是没没法执行普通的切片操作的,这是因为不知道它们的长度是多少(而且它们也没有实现索引),那么如何切片?解决方案:使用itertools.islice()来对迭代器和生成器做切片操作def count(n): while True: yield n n += 1 c = count(0) # 生成器的绝妙之处:它只会在迭代时才会运行,所以死循环也没有问题,返回一个generator# print(c[:]) # TypeError:原创 2021-02-21 13:06:29 · 403 阅读 · 0 评论 -
Python 依赖库管理哪家强?pip、pipreqs、 pigar、pip-tools、pipdeptree 任君挑选收集包
Python 依赖库管理哪家强?pip、pipreqs、 pigar、pip-tools、pipdeptree 任君挑选pipreqs搜索依赖库的范围是基于目录的方式,很有针对性搜索的依据是脚本中所 import 的内容可以在未安装依赖库的环境上生成依赖文件其中需注意,很可能遇到编码错误:UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in 。需要指定编码格式“--encoding=utf8”。#安装pip install.原创 2021-02-21 00:26:34 · 282 阅读 · 0 评论 -
字典转url
from urllib.parse import urlencodeparams = {'wd': 'python', 'ie': 'utf-8'}result = urlencode(params) # wd=python&ie=utf-8原创 2020-11-27 12:15:30 · 499 阅读 · 0 评论 -
txt配置文件读取
with open('配置.txt', 'r', encoding='utf-8')as filed: rr_list = filed.readlines() conf = {} for rr in rr_list: rr = rr.replace('\n', '') rr = rr.split('=') conf[rr[0]] = rr[1]原创 2020-11-24 15:34:14 · 516 阅读 · 0 评论 -
python调用rarfile进行解压rar压缩包时,报了如下错误
import rarfile,osdef un_rar(filename): rar = rarfile.RarFile(filename) # 判断同名文件夹是否存在,若不存在则创建同名文件夹 if os.path.isdir(os.path.splitext(filename)[0]): pass else: os.mkdir(os.path.splitext(filename)[0]) rar.extractall(os..原创 2022-11-09 17:03:30 · 1870 阅读 · 0 评论 -
python word docx中文教程 win32
https://blog.youkuaiyun.com/smile445/article/details/90402394原创 2020-04-09 10:15:26 · 367 阅读 · 0 评论 -
pywinauto 自动化
https://www.kancloud.cn/gnefnuy/pywinauto_doc/1193035原创 2020-04-24 23:56:24 · 354 阅读 · 0 评论 -
psutil模块教程
https://blog.youkuaiyun.com/cpongo3/article/details/88819885?ops_request_misc=&request_id=&biz_id=&utm_source=distribute.pc_search_result.none-task原创 2020-03-24 15:29:20 · 247 阅读 · 0 评论 -
Selenium 总结
SeleniumSelenium是一个Web的自动化测试工具,最初是为网站自动化测试而开发的,类型像我们玩游戏用的按键精灵,可以按指定的命令自动操作,不同是Selenium 可以直接运行在浏览器上,它支持所有主流的浏览器(包括PhantomJS这些无界面的浏览器)。Selenium 可以根据我们的指令,让浏览器自动加载页面,获取需要的数据,甚至页面截屏,或者判断网站上某些动作是否发生。...原创 2020-03-15 20:52:51 · 241 阅读 · 0 评论 -
url编码,解码
from urllib.parse import quote,unquotetext = "丽江"print(quote(text,'utf-8'))str = "%E9%A6%99%E5%A5%88%E5%84%BF%E5%8C%85%E6%96%B0%E6%AC%BE"print(unquote(str,'utf-8'))原创 2020-03-11 23:55:27 · 200 阅读 · 0 评论 -
sqlite
import sqlite3conn = sqlite3.connect('test.db')cursor = conn.cursor()#cursor.execute('create table page_url(url varchar(120) primary key,sta varchar(1))')#建表3#cursor.execute('create table xq_ur...原创 2020-03-08 22:44:53 · 151 阅读 · 0 评论 -
fastapi demo
from fastapi import FastAPIfrom pydantic import BaseModelimport uvicornapp = FastAPI()from Untitled2 import url_aoiclass Item(BaseModel): amazon: str = None@app.get("/")def read_root():...原创 2020-03-07 17:17:04 · 780 阅读 · 0 评论 -
Python-schema的使用 数据校验
schemahttps://blog.youkuaiyun.com/y472360651/article/details/81949653正则验证https://www.cnblogs.com/zhaijiahui/p/9248564.html原创 2020-02-20 13:23:18 · 881 阅读 · 0 评论 -
python正则过滤标点符号
import re# 过滤不了\\ \ 中文()还有————r1 = u'[a-zA-Z0-9’!"#$%&\'()*+,-./:;<=>?@,。?★、…【】《》?“”‘’![\\]^_`{|}~]+' # 用户也可以在此进行自定义过滤字符# 者中规则也过滤不完全r2 = "[\s+\.\!\/_,$%^*(+\"\']+|[+——!,。?、~@#¥%……&am...原创 2020-01-14 14:39:57 · 2135 阅读 · 0 评论 -
标点符号过滤去掉括号和括号内的所有内容
import re# 去掉括号和括号内的所有内容r4 = "\\【.*?】+|\\《.*?》+|\\#.*?#+|[.!/_,$&%^*()<>+""'?@|:~{}#]+|[——!\\\,。=?、:“”‘’¥……()《》【】]"text = "\崔芸,\\我爱=+你!【我//""们】~————结/婚'吧::!这.!!_#??()个‘’“”¥$主|意()不错......原创 2019-12-18 09:06:04 · 338 阅读 · 0 评论 -
python web并发异步测试
import asyncioimport aiohttpimport timeurl_lst_failed=[]url_lst_successed=[]async def get_info(url): async with aiohttp.ClientSession() as session: async with session.get(url,timeout...原创 2019-12-11 17:45:25 · 207 阅读 · 0 评论 -
linux后台运行python
直接用nohup运行nohup python xxxx.py > myout.out 2>&1 &大功告成。 想看看程序是否在运行ps aux|grep pythonhttps://www.jianshu.com/p/4041c4e6e1b0原创 2019-11-24 02:41:27 · 206 阅读 · 0 评论 -
asyncio 异步 并发
import asyncioasync def hello(): print("Hello world!") await asyncio.sleep(1) print("Hello again!")loop = asyncio.get_event_loop()tasks = [hello(), hello(),hello(), hello()]loop.run...原创 2019-11-19 21:20:57 · 181 阅读 · 0 评论 -
python乱码问题
python json.dumps中文乱码json.dumps在默认情况下,对于非ascii字符生成的是相对应的字符编码,而非原始字符,例如:>>> import json>>> js = json.loads('{"haha": "哈哈"}')>>> print json.dumps(js){"name": "\u54c8\u...原创 2019-11-18 10:03:50 · 119 阅读 · 0 评论 -
des加密解密
from pyDes import des, CBC, PAD_PKCS5import binascii# 秘钥8位KEY = 'ssbbssbb'def des_encrypt(s): """ DES 加密 :param s: 原始字符串 :return: 加密后字符串,16进制 """ secret_key = KEY iv...原创 2019-10-25 15:32:08 · 942 阅读 · 0 评论 -
python使用异步redis--aioredis
import asyncioimport aioredisloop = asyncio.get_event_loop()async def go(): conn = await aioredis.create_connection( ('localhost', 6379), loop=loop) await conn.execute('set', 'my...原创 2019-10-24 15:14:55 · 2763 阅读 · 0 评论 -
python---aiohttp的使用 python asyncio 获取协程返回值和使用callback 500并发测试
aiohttp教程https://www.cnblogs.com/ssyfj/p/9222342.html#14.clientsession-用于在多个连接之间同一网站共享cookie,请求头等https://www.cnblogs.com/callyblog/p/11216961.htmlimport asynciofrom aiohttp import webasy...原创 2019-10-24 14:22:21 · 2175 阅读 · 0 评论 -
完全卸载Python for ubuntu
https://blog.youkuaiyun.com/ken1583096683/article/details/80276269原创 2019-10-19 22:04:40 · 167 阅读 · 0 评论 -
pipenv 用法
pipenvversion 2018.7.1 支持完美的pip版本是pip18.0python -m pip install pip==18.0安装:pip3 install pipenvpipenv install # 默认为该目录创建一个python虚拟环境 位于 用户名.local/share/virtualenvs/项目目录名-随机字符串# 提供可选参数 --tw...原创 2019-10-18 11:37:50 · 149 阅读 · 0 评论 -
宝塔系统常用模块 常用命令
https://www.bt.cn/btcode.htmlFlask>=1.0.2Flask-Session>=0.3.1flask-sqlalchemy>=2.3.2#对远程服务器进行ssh命令或ftp文件操作paramiko>=2.6.0客户端和服务器之间的低延迟双向通信,例如数据监控、统计图实时变化更新等flask-socketio&g...原创 2019-10-16 22:15:24 · 364 阅读 · 0 评论 -
Python库大全,建议收藏留用!
作者:人云亦云链接:https://zhuanlan.zhihu.com/p/79526335来源:知乎著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。学Python,想必大家都是从爬虫开始的吧。毕竟网上类似的资源很丰富,开源项目也非常多。Python学习网络爬虫主要分3个大的版块:抓取,分析,存储当我们在浏览器中输入一个url后回车,后台会发生什么?...原创 2019-10-16 09:20:41 · 129 阅读 · 0 评论 -
申请免费SSL证书
https://blog.youkuaiyun.com/xs18952904/article/details/79262646原创 2019-10-19 18:38:59 · 809 阅读 · 0 评论 -
Python PIL库图像处理操作详解
https://www.linuxidc.com/Linux/2019-09/160566.htm原创 2019-10-19 18:39:07 · 654 阅读 · 0 评论 -
19年3月学习总结-XlsxWriter-selenium-requests-urllib3-yaml
python模块之XlsxWriterhttp://www.cnblogs.com/brightbrother/p/8671077.htmlpython2.X从json文件中读取数据进行unicode转码情况方法一str.decode('gb1312‘).encode('utf-8')https://blog.youkuaiyun.com/sinat_41292836/article/det...原创 2019-03-10 15:11:38 · 161 阅读 · 0 评论 -
反编译获取任何微信小程序源码(完)
https://blog.youkuaiyun.com/qq_33858250/article/details/80543815原创 2019-03-11 21:50:26 · 468 阅读 · 1 评论 -
Ubuntu下完全卸载nginx服务器
删除nginx,–purge包括配置文件sudo apt-get --purge remove nginx1自动移除全部不使用的软件包sudo apt-get autoremove1列出与nginx相关的软件 并删除显示的软件dpkg --get-selections|grep nginxsudo apt-get --purge remove nginxsudo apt-...原创 2019-04-05 16:14:09 · 710 阅读 · 0 评论 -
redis
string类型设置键值set key value例1:设置键为name值为itcast的数据set name itcast设置键值及过期时间,以秒为单位setex key seconds value例2:设置键为aa值为aa过期时间为3秒的数据setex aa 3 aa设置多个键值mset key1 value1 key2 value2 ...例3:设置键为'a1'值为'p...原创 2019-04-06 10:11:00 · 108 阅读 · 0 评论