![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
空中追风sk
这个作者很懒,什么都没留下…
展开
-
python jsonschema示例
参考:https://blog.csdn.net/swinfans/article/details/89231682https://www.jianshu.com/p/1711f2f24dcf?utm_campaign=hugoimport jsonschemaschema = { "type": "object", "properties": { "version_no": {"type": "string"}, "versions": {原创 2021-03-30 23:54:46 · 376 阅读 · 2 评论 -
sqlalchemy的使用
from sqlalchemy import Column, String, create_enginefrom sqlalchemy.orm import sessionmakerfrom sqlalchemy.ext.declarative import declarative_base# 创建模型的基类Base = declarative_base()class User(...原创 2020-04-24 22:05:43 · 161 阅读 · 0 评论 -
实验楼——图片转字符画
参考:https://www.shiyanlou.com/courses/370/learning/?id=1191自定义命令行参数:argparse模块灰度值指黑白图像中点的颜色深度,范围一般从0到255,白色为255,黑色为0,故黑白图片也称灰度图像。RGBRGB色彩模式是工业界的一种颜色标准,是通过对红®、绿(G)、蓝(B)三个颜色通道的变化以及它们相互之间的叠加来得到...原创 2019-12-01 22:59:29 · 143 阅读 · 0 评论 -
python——装饰器和MRO
使用场景:在不改变原函数结构时增加一些新的功能,比如想测试某个函数的运行时间或者运行的效率原理:函数被装饰后,原函数名其实已经指向了装饰器函数的内部函数@functools.wraps(func):将原函数对象的指定属性复制给包装函数对象repr(*args, **kwargs):将传递给它的对象都转为字符串vars(obj):可以将对象转为字典1.定义缓存装饰器import func...原创 2020-04-04 15:51:44 · 135 阅读 · 0 评论 -
python——日志
1.settings.pyLOGGING = { 'version': 1, # 指明dictConnfig的版本,目前就只有一个版本 'disable_existing_loggers': False, # 表示是否禁用django默认的日志配置,默认就是False 'formatters': { 'basic': { # 格式器的名字 ...原创 2020-03-27 23:09:17 · 140 阅读 · 0 评论 -
python——压缩目录
涉及知识点: - 遍历目录树:os.walk() - 压缩目录中的文件:zipfile原创 2019-03-10 22:47:00 · 377 阅读 · 0 评论 -
python密码加密
hashlib中的两种加密算法:sha1和MD5sha1:全称是Secure Hash Algorithm(安全哈希算法)sha1基于md5,加密后的数据比md5多32位因此,相对md5更加安全,同时运算速度较低# hashlib加密示例import hashlibpwd = 'sk123'#创建sha1对象sha1 = hashlib.sha1()#对字符进行加密,默认支持...原创 2019-03-12 19:49:45 · 2546 阅读 · 0 评论 -
python类中的@classmethod,@staticmethod,@property三种装饰器
参考:https://blog.csdn.net/weixin_43613053/article/details/84979916一、@classmethod类方法,需要一个cls参数,可以用类名或对象来调用class Post(models.Model): @classmethod def latest_posts(cls): return cls.obj...原创 2019-06-04 23:57:41 · 933 阅读 · 0 评论 -
python正则
1.元字符总结匹配单个字符:. […] [^…] \d \D \w \W \s \S匹配重复: * + ? {n} {m,n}匹配位置: ^ $ \A \Z \b \B其他: | () \2. python re模块regex = compile(pattern,flags = 0)功能:生成正则表达...原创 2019-05-03 21:20:37 · 161 阅读 · 0 评论 -
python PIL
涉及知识点: - 生成登陆验证码 - 实现单用户登陆 - 压缩图片原创 2019-05-04 23:01:08 · 138 阅读 · 0 评论 -
python----datetime模块
import datetime# 自定义日期和时间set_date = datetime.date(2018,1,31) # 2018-01-25 set_time = datetime.time(21,2,10) # 21:02:10# 组合日期和时间set_datetime = datetime.datetime.combine(set_date,set_time) ...原创 2019-05-11 22:19:29 · 289 阅读 · 0 评论 -
命令行翻译工具
命令行参数模块:argparse打包:PyInstaller1.程序文件import requests, time, hashlib, random, jsonimport argparse# 请求地址和请求头url = 'http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule'header...原创 2019-12-22 20:50:38 · 460 阅读 · 0 评论 -
windows环境下区分python2和3的pip
1.安装好python2和3后分别配置好环境变量;2.将python2安装目录中python.exe pythonw.exe更改为python2.exe和pythonw2.exe;3.给python2重新安装pippython2 -m pip install --upgrade pip --force-reinstall4.查看结果C:\Users\77962>pip2 -V...原创 2019-11-10 19:07:36 · 279 阅读 · 0 评论 -
python os模块
import os, time# 判断目录是否存在,不存在则创建if not os.path.exists('os-test'): os.mkdir('os-test')# 切换工作目录os.chdir(os.getcwd() + '/os-test')with open('1.txt','w') as f: f.write('1111')with open('...原创 2019-05-04 23:18:12 · 113 阅读 · 0 评论 -
Lintcode:671. 循环单词
一个单词通过循环右移获得的单词,我们称这些单词都为一种循环单词。 现在给出一个单词集合,需要统计这个集合中有多少种不同的循环单词。样例: 给出 dict = ["picture", "turepic", "icturep", "word", "ordw", "lint"] 返回 3 "picture", "turepic",原创 2019-01-29 23:27:32 · 250 阅读 · 0 评论 -
python:标准输入输出函数的使用
python标准输入输出:sys.stdin和sys.stdout#写一个函数,实现print函数的功能import sysdef myprint(*args,sep=’ ‘,end=’\n’):flag = Falsefor i in args:if flag:sys.stdout.write(sep)sys.stdout.write(str(i))flag = Truesy...原创 2019-02-27 22:46:29 · 1124 阅读 · 0 评论 -
python爬取实时天气
代码如下:需要注意的是返回的是已编译的json字符串,需要转为python对象,不然打开后中文显示的是unicode编码import requestsimport jsonurl = 'https://www.tianqiapi.com/api/?'headers = {'User-Agent':'Mozilla/5.0'}city = input('请输入查询城市:')param...原创 2019-04-08 18:25:58 · 1676 阅读 · 0 评论 -
python爬取视频----blob加密
视频地址经过blob加密,查看请求找到m3u8地址,获取ts视频文件地址和key爬取ts文件并使用AES解密保存原创 2019-05-12 14:09:25 · 10110 阅读 · 5 评论 -
python爬取有道翻译
1.有道翻译的请求参数salt,sign和ts须动态设置# http://fanyi.youdao.com/translate_o?smartresult=dict&smartresult=rule# i: tree# from: AUTO# to: AUTO# smartresult: dict# client: fanyideskweb# salt: 155573405...原创 2019-04-20 15:10:13 · 217 阅读 · 0 评论 -
python实现定时关机
转载:https://www.cnblogs.com/summerise8090/p/8340070.html构建自定义的日期,时间和日期时间对象win32弹窗import win32api,win32conimport osfrom datetime import date, time, datetimefrom time import sleepdef shundown(dow...转载 2019-04-30 23:28:49 · 1022 阅读 · 0 评论 -
python包管理工具pip和虚拟环境
涉及知识点: 1. 包管理工具:pip 2. 依赖管理:pipreqs 3. 虚拟环境:venv原创 2019-05-02 11:20:02 · 541 阅读 · 0 评论 -
分布式任务队列——celery+redis
一.基本信息1.简介Celery是一个分布式消息队列,能够处理大量消息,是一个专注于实时处理的任务队列,同时也支持异步任务调度。Celery 不仅可以单机运行,也能够同时在多台机器上运行,甚至可以跨数据中心。2.组成任务队列客户端将要执行任务的消息放入任务队列,执行节点worker进程持续监控队列,有新任务时就取出来执行,即生产者-消费者模型,客户端作为生产者,执行节点workerb...原创 2019-07-27 18:01:47 · 2441 阅读 · 0 评论