Python 检查文件是否存在

Posted on Tue 07 February 2017 in Python

检查文件或文件夹路径是否存在

import os.path
os.path.exists(path)

功能:检查一个路径是否存在,存在时返回True,否则返回False

检查文件是否存在

import os.path
os.path.isfile(file_path)

功能:检查一个文件路径是否存在,如果文件路径存在并且是一个普通文件则返回True,否则返回False

检查文件夹是否存在

import os.path
os.path.isdir(dir_path)

功能:检查一个文件夹路径是否存在,如果文件夹路径存在并且是一个文件夹则返回True,否则返回False

面向对象的方法

Python 3.4 开始引入了新的路径 API,pathlib模块提供了面向对象的方法 ...


Continue reading

MySQL 使用笔记

Posted on Wed 04 January 2017 in MySQL, Linux

更新到 Ubuntu 16.04 后出现 ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory 的解决办法

pip uninstall MySQL-python
pip install --no-binary MySQL-python MySQL-python

或者

pip uninstall mysqlclient
pip install --no-binary mysqlclient mysqlclient

去除重复的数据(并建立 Unique 索引)

ALTER IGNORE TABLE table_name
ADD UNIQUE INDEX idx_name(field1 ...

Continue reading

Training the dependency with spaCy

Posted on Wed 21 December 2016 in spaCy • Tagged with spaCy, Machine Learning, Natural Language Processing

Training the named entity recognizer with spaCy

Posted on Wed 21 December 2016 in spaCy • Tagged with spaCy, Machine Learning, Natural Language Processing

Training the part-of-speech tagger with spaCy

Posted on Wed 21 December 2016 in spaCy • Tagged with spaCy, Machine Learning, Natural Language Processing

Redis list 源码

Posted on Thu 08 December 2016 in Redis, C

Files

  • adlist.h 头文件,定义 list 数据结构,一些宏以及函数原型声明。
  • adlist.c 函数的实现

Data Structure

list 节点的数据结构 listNode

typedef struct listNode {
    struct listNode *prev;
    struct listNode *next;
    void *value;
} listNode;

prev 指向前一个节点,next指向下一个节点,value存储数据的指针。

list 迭代器的数据结构 listIter

typedef struct listIter {
    listNode *next;
    int direction;
} listIter;

next 指向下一个返回的节点,direction 指定迭代的方向:AL_START_HEAD从头开始迭代,而AL_START_TAIL 从尾部开始迭代 ...


Continue reading

TensorFlow Denoising Autoencoder

Posted on Mon 05 December 2016 in TensorFlow • Tagged with TensorFlow, Deep Learning, Machine Learning

TensorFlow Autoencoder

Posted on Sat 03 December 2016 in TensorFlow • Tagged with TensorFlow, Deep Learning, Machine Learning

Kaggle Competition: Leaf Classification

Posted on Fri 02 December 2016 in Kaggle • Tagged with Kaggle, Machine Learning, Decision Tree, Classification

TensorFlow Modern Deep Convolutional Neural Network

Posted on Thu 01 December 2016 in TensorFlow • Tagged with TensorFlow, Deep Learning, Machine Learning