自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Rouckie的博客

选择大于努力,努力带来机会!

  • 博客(28)
  • 收藏
  • 关注

原创 获取两个时间戳之间的所有日期点

获取两个时间戳之间的所有日期点

2023-03-02 10:22:27 279

原创 nohup命令的应用

nohup命令--实例解决Linux关闭终端(关闭SSH等)后运行的程序或者服务自动停止【后台运行程序】

2022-03-08 11:27:49 497

原创 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 2368

原创 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 1640

转载 爬虫学习路径图

2019-04-24 14:41:34 650 1

原创 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 985

原创 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 927

原创 多线程的简单实现

import timeimport threadingfrom queue import Queueclass Multithreading(object): def __init__(self): """ 初始化队列 """ self.list_page_queue = Queue(maxsize=100) #...

2019-04-24 14:28:04 175

原创 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 1026

原创 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 162

原创 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 5268

原创 日期简单的判断比较, 设定截止日期

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 754

原创 删除,移动文件夹中的特定文件

# --*-- 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 173

原创 删除列表list中的空字符串元素

test = ["", "a"]mytest = [i for i in test if i != '']

2019-01-18 16:16:50 6807 4

原创 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 1041

原创 统计单个文件的行数

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 207

原创 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 1082 1

原创 uuid的简单实现

import uuidfor i in range(10): doc_name = uuid.uuid1().hex # .hex意在去除uuid中的横杠(-) print(doc_name) 

2019-01-12 15:04:32 626

原创 一次性替换多个字符

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 2094

原创 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 385

原创 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 6336

原创 pip 快速安装所需包的方法

1. pip freeze &gt; requirements.txt   输出一个已安装包的列表到一个文件2. pip install -r  requirements.txt  一次性安装应用的所有需求的包文件

2018-12-11 17:47:39 629

原创 python 读取文本每一行的简单实现

file_path = "" # 文件路径for line in open(file_path): print(line) # 对每一行进行操作即可 

2018-12-07 23:15:55 15387 1

转载 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 2045

原创 添加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 5674

原创 URL 中的中文处理

from urllib.parse import quoteimport stringurl = r'http://www.qixin.com/search?key=黑龙江律师事务所&amp;page=1'url_1 = quote(url, safe=string.printable) # safe表示可以忽略的字符url = quote(url) # safe表示可以忽略的字符...

2018-09-15 16:21:41 228

原创 For循环7行代码搞定九九乘法表

      相信刚开始Python入门的小伙伴都有打印过九九乘法表, 下面分享一个用for循环实现的打印方法.就7行代码,可以放在IDE中debug一下,体会一下简单巧妙的实现过程! !for i in list(range(1, 10)): for j in list(range(1, 10)): if j &lt;= i: print("%d*%...

2018-03-09 21:55:38 862

原创 5分钟搞懂Python中实例方法,类方法和静态方法

1. 实例方法: 由实例对象调用且至少有一个self参数; 执行实例方法时,自动将调用该方法的对象赋值给self.2.类方法: 由类对象调用且至少有一个cls参数; 执行类方法时,自动将调用该方法的类赋值给cls.3.静态方法: 由类调用, 没有默认参数.class Foo(object): def __init__(self, name): self.name = nam...

2018-03-09 21:26:58 376

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除