随笔 - 836  文章 - 1 评论 - 40 阅读 - 102万
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

随笔分类 -  python

上一页 1 2 3 4 下一页
Python3中正则模块re.compile、re.match及re.search函数
摘要:参考:https://www.jb51.net/article/141830.htm 官网:https://docs.python.org/3/library/re.html re.compile() 函数 编译正则表达式模式,返回一个对象。可以把常用的正则表达式编译成正则表达式对象,方便后续调用及 阅读全文
posted @ 2019-11-19 16:30 lshan 阅读(552) 评论(0) 推荐(0) 编辑
python3 requests 使用proxy代理 ,cookies
摘要:proxy代理 (通用代理) import requests url='http://docs.python-requests.org/en/master/' proxies={ 'http':'127.0.0.1:8080', 'https':'127.0.0.1:8080' } r = requ 阅读全文
posted @ 2019-11-17 22:06 lshan 阅读(36001) 评论(0) 推荐(0) 编辑
python time装饰器log 类似Java 中注解 装饰器,timer or log
摘要:装饰器,timer or log 打印日志以及方法运行时间 对于异步方法: from functools import wraps import traceback import time def async_time_fun(func): @wraps(func) async def log(*a 阅读全文
posted @ 2019-11-17 16:15 lshan 阅读(400) 评论(0) 推荐(0) 编辑
python json(dict) jsonpath 获取字典路径下的值
摘要:def json_path_value(jsondict,path): try: num=1 pahts = path.split(".") mydict={} for p in pahts: if num==1: mydict = jsondict[p+""] num=num+1 else: my 阅读全文
posted @ 2019-11-15 12:00 lshan 阅读(1870) 评论(0) 推荐(0) 编辑
MongoUtils mongo utils python
摘要:如果是 pymongo==4.x pls pip3 install pymongo==4.5.0 client = pymongo.MongoClient(host="192.168.12.153", port=27017, username="root", password="root", aut 阅读全文
posted @ 2019-11-14 11:01 lshan 阅读(504) 评论(0) 推荐(0) 编辑
pip 镜像加速
摘要:方式1: 每次指定 目前用 pip 安装软件时有时候软件包的源位于境外,所以导致安装速度很慢,建议使用国内的一些镜像源进行安装: 阿里云:https://mirrors.aliyun.com/pypi/simple/豆瓣网:http://pypi.douban.com/simple/清华大学:htt 阅读全文
posted @ 2019-11-06 22:26 lshan 阅读(143) 评论(0) 推荐(0) 编辑
python3 搭建ftp 文件服务器 docker
该文被密码保护。
posted @ 2019-11-02 22:32 lshan 阅读(13) 评论(0) 推荐(0) 编辑
python http 把自己的电脑变成一个静态服务
摘要:就可以运行起来静态服务。平时用它预览和下载文件太方便了。 在终端中输入命令: python2中 python3中 阅读全文
posted @ 2019-11-02 22:18 lshan 阅读(357) 评论(0) 推荐(0) 编辑
python 使用property取代getter和setter方法
摘要:使用property取代getter和setter方法 @property成为属性函数,可以对属性赋值时做必要的检查,并保证代码的清晰短小,主要有2个作用 将方法转换为只读 重新实现一个属性的设置和读取方法,可做边界判定 运行结果 阅读全文
posted @ 2019-11-02 21:37 lshan 阅读(825) 评论(0) 推荐(0) 编辑
python 装饰器
摘要:装饰器 装饰器是程序开发中经常会用到的一个功能,用好了装饰器,开发效率如虎添翼,所以这也是Python面试中必问的问题,但对于好多初次接触这个知识的人来讲,这个功能有点绕,自学时直接绕过去了,然后面试问到了就挂了,因为装饰器是程序开发的基础知识,这个都不会,别跟人家说你会Python, 看了下面的文 阅读全文
posted @ 2019-11-02 21:04 lshan 阅读(169) 评论(0) 推荐(0) 编辑
python 闭包
摘要:python 闭包 1. 函数引用 运行结果: 2. 什么是闭包 运行结果: 3. 闭包再理解 内部函数对外部函数作用域里变量的引用(非全局变量),则称内部函数为闭包。 启动python解释器 4. 看一个闭包的实际例子: 这个例子中,函数line与变量a,b构成闭包。在创建闭包的时候,我们通过li 阅读全文
posted @ 2019-11-02 21:03 lshan 阅读(184) 评论(0) 推荐(0) 编辑
kafka python 指定分区消费 与 offset
摘要:指定offset: #pip install kafka-pythonimport gzip from kafka import KafkaConsumer from kafka import TopicPartition consumer = KafkaConsumer(bootstrap_ser 阅读全文
posted @ 2019-11-01 18:58 lshan 阅读(12133) 评论(0) 推荐(1) 编辑
python @retry request
摘要:依赖:pip install retrying 在爬虫代码的编写中,requests请求网页的时候常常请求失败或错误,一般的操作是各种判断状态和超时,需要多次重试请求,这种情况下,如果想优雅的实现功能,可以学习下retrying包下的retry装饰器的使用 安装:pip install retryi 阅读全文
posted @ 2019-10-28 14:36 lshan 阅读(684) 评论(0) 推荐(0) 编辑
python str byte 互转
摘要:# bytes object b = b"example" # str object s = "example" # str to bytes bytes(s, encoding = "utf8") # bytes to str str(b, encoding = "utf-8") # an alternative ... 阅读全文
posted @ 2019-10-17 12:25 lshan 阅读(550) 评论(0) 推荐(0) 编辑
python -config-ini 配置文件的使用
摘要:参考: https://www.cnblogs.com/hanmk/p/9843136.html https://www.cnblogs.com/wangjian1226/p/10448752.html python使用自带的configparser模块用来读取配置文件,配置文件的形式类似windo 阅读全文
posted @ 2019-10-15 00:13 lshan 阅读(1892) 评论(0) 推荐(0) 编辑
python mysql
摘要:参考: https://www.runoob.com/python3/python3-mysql.html 阅读全文
posted @ 2019-10-12 18:48 lshan 阅读(144) 评论(0) 推荐(0) 编辑
Schema一种优雅的数据验证方式 validation python
摘要:参考:https://segmentfault.com/a/1190000011777230 https://blog.csdn.net/weixin_34323858/article/details/88951728 阅读全文
posted @ 2019-10-12 14:12 lshan 阅读(1017) 评论(0) 推荐(0) 编辑
python 多线程 (线程池的几种使用)(2)
摘要:参考自定义线程池:https://www.cnblogs.com/zhang293/p/7954353.html 原密解析: https://www.jianshu.com/p/b9b3d66aa0be 最佳线程数的获取: 1、通过用户慢慢递增来进行性能压测,观察QPS(即每秒的响应请求数,也即是最 阅读全文
posted @ 2019-10-11 15:29 lshan 阅读(720) 评论(0) 推荐(0) 编辑
python 多线程-带返回值 (1)
摘要:一般线程的使用: 参考; https://www.runoob.com/python3/python3-multithreading.html 带返回值 阅读全文
posted @ 2019-10-11 15:24 lshan 阅读(1053) 评论(1) 推荐(0) 编辑
python email 邮件
摘要:. . .参考:https://www.runoob.com/python3/python3-smtp.html #encoding=utf-8 ''' Created on 2019年10月11日 @author: sea ''' import smtplib from email.mime.te 阅读全文
posted @ 2019-10-11 13:54 lshan 阅读(226) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 下一页
点击右上角即可分享
微信分享提示