随笔分类 -  Python 小记

python常用正则表达式
摘要:import re def extract_emails(text): """提取文本中的所有邮箱地址""" pattern = r"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}" return re.findall(pattern, text) de 阅读全文

posted @ 2025-12-15 17:35 fengZQ 阅读(4) 评论(0) 推荐(0)

Python collections 模块详解
摘要:collections 模块提供了Python内置容器的替代实现,具有更强的功能和性能优化。下面介绍其中最常用的几个类: 1. Counter(计数器) 用于统计可哈希对象的频次 python from collections import Counter # 创建Counter对象 words = 阅读全文

posted @ 2025-12-12 08:53 fengZQ 阅读(28) 评论(0) 推荐(0)

python 第三方包大全
摘要:https://www.lfd.uci.edu/~gohlke/pythonlibs/ http://mirrors.aliyun.com/pypi/simple 阅读全文

posted @ 2022-07-29 10:12 fengZQ 阅读(117) 评论(0) 推荐(0)

python bottle小记
摘要:# coding=utf-8import bottle @bottle.route('/url/url', method=['GET','POST'])def big_data(): # 获取请求参数 trans_user_type = bottle.request.GET.get('trans_u 阅读全文

posted @ 2022-06-30 09:58 fengZQ 阅读(43) 评论(0) 推荐(0)

flash 学习笔记
摘要:一、安装环境 1. 查看是否安装了virtualenv virtualenv --version 2. 安装虚拟环境 pip install virtualenv pip install virtualenvwrapper 3. 若提示找不到mkvirtualenv命令,需配置环境变量 1)创建目录 阅读全文

posted @ 2021-04-09 15:32 fengZQ

python字典排序
摘要:1. 字典排序 d={'a':1,'c':3,'b':2} d1={k:d[k] for k in sorted(d)} 阅读全文

posted @ 2020-10-09 09:46 fengZQ 阅读(76) 评论(0) 推荐(0)

python分包存放java堆栈信息
摘要:# coding=utf-8 import os import time path = os.getcwd() index = 0 while True: # 当前时间戳 timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) 阅读全文

posted @ 2020-06-10 19:49 fengZQ 阅读(226) 评论(0) 推荐(0)

python 返回当前文件夹下的所有文件的绝对路径;打印文件中的中文字符
摘要:# coding=utf-8 import re import os path = os.path.abspath('.') def all_path(dirname): result = [] for maindir, subdir, file_name_list in os.walk(dirna 阅读全文

posted @ 2020-03-31 14:37 fengZQ 阅读(623) 评论(0) 推荐(0)

python 虚拟环境及项目快速迁移
摘要:一、是否安装了virtualenv:virtualenv —version 二、安装虚拟环境: pip install virtualenvpip install virtualenvwrapper 三、配置 virtualenv:1. mkdir $HOME/.virtualenvs 2. vim 阅读全文

posted @ 2020-03-19 10:22 fengZQ 阅读(668) 评论(0) 推荐(0)

python3 解决bytes转str时抛“UnicodeDecodeError”异常
摘要:1. 修改字符集参数,一般这种情况出现得较多是在国标码(GBK)和utf8之间选择出现了问题。 2. 出现异常报错是由于设置了decode()方法的第二个参数errors为严格(strict)形式造成的,因为默认就是这个参数,将其更改为ignore等即可。例如: b"\xac\xed\x00\x05 阅读全文

posted @ 2020-02-21 10:18 fengZQ 阅读(946) 评论(0) 推荐(0)

python 日期运算
摘要:import datetime timeNow = datetime.datetime.now() # 当前日期 today = timeNow.strftime('%Y%m%d%H%M%S') # 昨天 yesterday = (timeNow - datetime.timedelta(days=1)).strftime('%Y%m%d%H%M%S') # 二十天前 twentyDaysAg... 阅读全文

posted @ 2019-02-20 17:50 fengZQ 阅读(2686) 评论(0) 推荐(0)

python项目在不同PC间环境迁移
摘要:https://www.cnblogs.com/zelos/p/7439599.html 阅读全文

posted @ 2019-02-20 11:07 fengZQ 阅读(966) 评论(0) 推荐(0)

requests模块上传文件
摘要:files = {'file': open('test11.log', 'rb')}res = requests.post( url, data={ 'key1': value, 'key2': value, 'key3': value }, files=files) 阅读全文

posted @ 2018-11-27 19:25 fengZQ 阅读(439) 评论(0) 推荐(0)

Python-文件和文件夹的移动、复制、删除、重命名
摘要:转自:http://blog.csdn.net/woshisangsang/article/details/74360612 阅读全文

posted @ 2018-03-09 09:31 fengZQ 阅读(43524) 评论(0) 推荐(1)

Python Excel及setuptool安装
摘要:1. 安装openpyxl模块 pip install openpyxl 2. 代码 获取最大行列值 print(table.max_row)print(table.max_column) 参考: https://www.cnblogs.com/sun-haiyu/p/7096423.html xl 阅读全文

posted @ 2018-02-07 15:54 fengZQ 阅读(488) 评论(0) 推荐(0)

Python 异常处理——处理默认错误类型以外错误
摘要:Python 异常处理之处理默认错误类型以外错误 阅读全文

posted @ 2018-01-04 15:02 fengZQ 阅读(864) 评论(0) 推荐(0)

Python 编程(小试水)
摘要:一. Python 冒泡法排序def sequence(arrays=list()): def desc(): for i in range(1, len(arrays)): for j in range(len(arrays) - i): if arrays[j] arrays[j + 1]: ... 阅读全文

posted @ 2017-12-11 22:37 fengZQ 阅读(331) 评论(0) 推荐(0)

导航