平时积累
Rouckie
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
获取两个时间戳之间的所有日期点
获取两个时间戳之间的所有日期点原创 2023-03-02 10:22:27 · 429 阅读 · 0 评论 -
nohup命令的应用
nohup命令--实例解决Linux关闭终端(关闭SSH等)后运行的程序或者服务自动停止【后台运行程序】原创 2022-03-08 11:27:49 · 598 阅读 · 0 评论 -
一次性替换多个字符
temp_str = "abcdefgh" # 待替换字符串multi_map = temp_str.maketrans({"a": "0", "g": "0"}) # 多个映射,实现多个替换ret = temp_str.translate(multi_map) # 一次性替换print(ret)# 注意此方法mu...原创 2019-01-10 01:15:50 · 2331 阅读 · 0 评论 -
python 往ES中简单插入数据
# -*- coding: utf-8 -*-from elasticsearch import Elasticsearches = Elasticsearch(hosts="10.109.24.153", port=9200)es.indices.create(index="cggg", ignore=400)data = {"name": "小明", "age": "8"原创 2019-02-27 16:14:25 · 5423 阅读 · 0 评论 -
日期简单的判断比较, 设定截止日期
import datetimed1 = datetime.datetime.strptime('2019-03-05', '%Y-%m-%d')d2 = datetime.datetime.strptime('2019-01-01', '%Y-%m-%d')if d1 >= d2: print("待执行的程序!")date_str = “2019-05-12”da...原创 2019-02-19 17:31:19 · 874 阅读 · 0 评论 -
selenium 简单试用
# --*-- coding: utf-8 --*--from selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import ...原创 2019-03-19 11:52:26 · 227 阅读 · 0 评论 -
ES 上传,更新数据
import jsonimport hashlibfrom pprint import pprintfrom elasticsearch import Elasticsearches = Elasticsearch(hosts="10.109.24.153", port=9200)es.indices.create(index="newlegalindex", ignore=400...原创 2019-03-27 17:37:03 · 1163 阅读 · 0 评论 -
多线程的简单实现
import timeimport threadingfrom queue import Queueclass Multithreading(object): def __init__(self): """ 初始化队列 """ self.list_page_queue = Queue(maxsize=100) #...原创 2019-04-24 14:28:04 · 248 阅读 · 0 评论 -
pymongo连接MongoDB的简单实现
import pymongoclient = pymongo.MongoClient(host='localhost', port=27017)db = client.test_mongodbcollection = db.students_infostudent = {"id": "002", "name": "李灿", "age": 20...原创 2019-04-24 14:33:33 · 1024 阅读 · 0 评论 -
pymysql连接MySQL的简单实现
import pymysqldb = pymysql.connect(host='localhost', user='root', password='123456', port=3306, db='test_mysql')cursor = db.cursor()data = { "name": "Tom"}table = "students_info"keys = ", ...原创 2019-04-24 14:36:10 · 1096 阅读 · 0 评论 -
爬虫学习路径图
转载 2019-04-24 14:41:34 · 774 阅读 · 1 评论 -
oss连接的简单实现与文件的简单获取
# -*- coding: utf-8 -*-import oss2class Test(object): def __init__(self): self.auth = oss2.Auth('LTAIwW2SiGVPJ4IL', 'P7n5DFASr2WLwJQV3IAKpIAlqVP12p') # 阿里账号 self.bucket = oss...原创 2019-04-24 14:51:52 · 1770 阅读 · 0 评论 -
xpath的简单应用,常见li标签分组
# coding=utf-8from lxml import etreetext = ''' <div> <ul> <li class="item-1"><a>first item</a></li> <li class="item-1"><a href="link2....原创 2019-04-24 14:57:58 · 2534 阅读 · 0 评论 -
删除,移动文件夹中的特定文件
# --*-- coding:utf-8 --*--import osimport shutilfrom lxml import etreepath = "/Users/rouckiechen/Desktop/china_court_result/guojia"dst_path = "/Users/rouckiechen/Desktop/china_court_result/unkn...原创 2019-01-18 16:23:04 · 269 阅读 · 0 评论 -
删除列表list中的空字符串元素
test = ["", "a"]mytest = [i for i in test if i != '']原创 2019-01-18 16:16:50 · 6991 阅读 · 4 评论 -
Scrapy使用阿布云代理
1.打开middlewares.py文件2.添加代理类import base64 """ 阿布云代理配置"""proxy_server = "http://http-dyn.abuyun.com:9020"proxy_user = "HEWGR9329K68Z11D"proxy_pass = "ACEBFFCDFE62615F"proxy_auth = "Ba转载 2018-11-29 20:08:16 · 2212 阅读 · 0 评论 -
添加chromedriver 到Mac环境变量
1. 下载chromedriver_mac64.zip 2.解压得到 3.把解压后的文件放到/usr/local/bin/下,结果像这样:/usr/local/bin/chromedriver(1) cd /usr/local/bin/(2) open .(3) 把 拖进来 4.添加环境变量export PATH=$PATH:/usr/loc...原创 2018-11-26 19:44:32 · 6321 阅读 · 0 评论 -
python 读取文本每一行的简单实现
file_path = "" # 文件路径for line in open(file_path): print(line) # 对每一行进行操作即可原创 2018-12-07 23:15:55 · 15523 阅读 · 1 评论 -
response = requests.get().json() 的使用、urlretrieve(url=url, filename="test.jpg")的使用
import requestsfrom urllib.request import urlretrieveheros_url = "http://gamehelper.gm825.com“# rep如果是json,就可以像下面这样用req = requests.get(url=heros_url, headers=headers).json() # .json()的使用prin...原创 2018-12-19 19:17:56 · 6524 阅读 · 0 评论 -
deque双向队列的简单实现与使用
from collections import dequedq = deque(maxlen=2) # 创建,限制大小for i in range(101): # 右边添加单个元素 dq.append(i) # 左边添加单个元素 dq.appendleft(i) # 右边添加列表 dq.extend([i]) # 左边添加列表...原创 2018-12-21 11:41:27 · 469 阅读 · 0 评论 -
pip 快速安装所需包的方法
1. pip freeze > requirements.txt 输出一个已安装包的列表到一个文件2. pip install -r requirements.txt 一次性安装应用的所有需求的包文件原创 2018-12-11 17:47:39 · 752 阅读 · 0 评论 -
uuid的简单实现
import uuidfor i in range(10): doc_name = uuid.uuid1().hex # .hex意在去除uuid中的横杠(-) print(doc_name)原创 2019-01-12 15:04:32 · 749 阅读 · 0 评论 -
python 统计文件夹,文件数目
import osdirnum = 0filenum = 0path = '目标文件夹路径'for lists in os.listdir(path): sub_path = os.path.join(path, lists) print(sub_path) if os.path.isfile(sub_path): filenum = filen...原创 2019-01-12 15:09:48 · 1173 阅读 · 1 评论 -
统计单个文件的行数
count = -1for count, line in enumerate(open("目标文件路径", "r", encoding="utf-8")): pass # print(count, line)count += 1print("统计数目为: %s" % count)原创 2019-01-12 17:30:26 · 304 阅读 · 0 评论 -
re.split() 分割文本
# --*-- coding:utf-8 --*--import re# 用特定字符去分割文本全文test_str = "第1章第一条哈哈哈哈哈会大幅度 第二章案件发奖金第三条阿道夫"ret = re.split(r"(第\w+?[章条])", test_str)print(ret) ...原创 2019-01-18 16:14:38 · 1157 阅读 · 0 评论
分享