原创 oss連接的簡單實現與文件的簡單獲取

# -*- coding: utf-8 -*- import oss2 class Test(object): def __init__(self): self.auth = oss2.Auth('LTAIw

原创 日期簡單的判斷比較, 設定截止日期

import datetime d1 = datetime.datetime.strptime('2019-03-05', '%Y-%m-%d') d2 = datetime.datetime.strptime('2019-01-01

原创 多線程的簡單實現

import time import threading from queue import Queue class Multithreading(object): def __init__(self): "

原创 pymongo連接MongoDB的簡單實現

import pymongo client = pymongo.MongoClient(host='localhost', port=27017) db = client.test_mongodb collection = db.st

原创 pymysql連接MySQL的簡單實現

import pymysql db = pymysql.connect(host='localhost', user='root', password='123456', port=3306, db='test_mysql') cur

原创 xpath的簡單應用,常見li標籤分組

# coding=utf-8 from lxml import etree text = ''' <div> <ul> <li class="item-1"><a>first item</a></li>

原创 爬蟲學習路徑圖

原创 ES 上傳,更新數據

import json import hashlib from pprint import pprint from elasticsearch import Elasticsearch es = Elasticsearch(host

原创 selenium 簡單試用

# --*-- coding: utf-8 --*-- from selenium import webdriver from selenium.webdriver.common.by import By from selenium.

原创 python 往ES中簡單插入數據

# -*- coding: utf-8 -*- from elasticsearch import Elasticsearch es = Elasticsearch(hosts="10.109.24.153", port=9200)

原创 日期簡單的判斷比較

import datetime d1 = datetime.datetime.strptime('2019-03-05', '%Y-%m-%d') d2 = datetime.datetime.strptime('2019-01-01

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

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

原创 刪除,移動文件夾中的特定文件

# --*-- coding:utf-8 --*-- import os import shutil from lxml import etree path = "/Users/rouckiechen/Desktop/china_co

原创 re.split() 分割文本

# --*-- coding:utf-8 --*-- import re # 用特定字符去分割文本全文 test_str = "第1章第一條哈哈哈哈哈會大幅度 第二章案件發獎金第三條阿道夫" ret = re.split(r"(第

原创 uuid的簡單實現

import uuid for i in range(10): doc_name = uuid.uuid1().hex # .hex意在去除uuid中的橫槓(-) print(doc_name)