chinapnr / fishbase

自主开发、整理的一套 Python 基础函数库,涵盖 system 系统增强包、logger 日志记录增强包、file 文件处理增强包、 date 日期处理函数包、data 数据信息处理函数包、csv 处理增强函数包、crypt 加密/编码增强包等,可减少程序开发工作量、降低引用复杂度。
MIT License
94 stars 29 forks source link

.. image:: https://travis-ci.org/chinapnr/fishbase.svg?branch=master :target: https://travis-ci.org/chinapnr/fishbase .. image:: https://coveralls.io/repos/github/chinapnr/fishbase/badge.svg?branch=master :target: https://coveralls.io/github/chinapnr/fishbase?branch=master .. image:: https://readthedocs.org/projects/fishbase/badge/?version=latest :target: https://fishbase.readthedocs.io/en/latest/?badge=latest .. image:: https://ci.appveyor.com/api/projects/status/ecskod12wy8fvkxu?svg=true :target: https://ci.appveyor.com/project/itaa/fishbase

fishbase 简介

fishbase 是由我们开发和整理的一套 Python基础函数库,将我们平时在开发 Python项目时候的各类工具函数汇聚到一起,方便集中管理和使用。希望对你也有所帮助,也适合初学 Python 的朋友通过代码来学习。

fishbase 最新版本为 v1.6,支持 Python 3.5-3.10,绝大部分函数也能工作在 Python 2.7下,但是我们不推荐使用 Python 2.7。

fishbase 主要有以下功能模块:

+-------------------------------------------------------------------------------+--------------------------------------+ | 模块 | 功能函数 | +===============================================================================+======================================+ | fish_common <https://fishbase.readthedocs.io/en/latest/fish_common.html>_ | 基本函数包 | +-------------------------------------------------------------------------------+--------------------------------------+ | fish_crypt <https://fishbase.readthedocs.io/en/latest/fish_crypt.html>_ | 加密数据函数包 | +-------------------------------------------------------------------------------+--------------------------------------+ | fish_csv <https://fishbase.readthedocs.io/en/latest/fish_csv.html>_ | csv处理增强函数包 | +-------------------------------------------------------------------------------+--------------------------------------+ | fish_data <https://fishbase.readthedocs.io/en/latest/fish_data.html>_ | 数据处理函数包,包括银行卡、身份证等 | +-------------------------------------------------------------------------------+--------------------------------------+ | fish_date <https://fishbase.readthedocs.io/en/latest/fish_date.html>_ | 日期处理增强函数包 | +-------------------------------------------------------------------------------+--------------------------------------+ | fish_file <https://fishbase.readthedocs.io/en/latest/fish_file.html>_ | 文件处理增强函数包 | +-------------------------------------------------------------------------------+--------------------------------------+ | fish_logger <https://fishbase.readthedocs.io/en/latest/fish_logger.html>_ | 日志记录增强函数包 | +-------------------------------------------------------------------------------+--------------------------------------+ | fish_project <https://fishbase.readthedocs.io/en/latest/fish_project.html>_ | 项目目录结构生成函数包 | +-------------------------------------------------------------------------------+--------------------------------------+ | fish_random <https://fishbase.readthedocs.io/en/latest/fish_random.html>_ | 随机数据生成增强函数包 | +-------------------------------------------------------------------------------+--------------------------------------+ | fish_system <https://fishbase.readthedocs.io/en/latest/fish_system.html>_ | 系统增强函数包 | +-------------------------------------------------------------------------------+--------------------------------------+

安装

.. code:: shell

通过 pip 进行安装或者更新

pip install -U fishbase

fishbase 功能举例

获取文件的绝对路径

.. code:: python

from fishbase.fish_files import get_abs_filename_with_sub_path print(get_abs_filename_with_sub_path('/etc', 'hosts')) (True, '/etc/hosts')

根据时间戳获取时间间隔

.. code:: python

from fishbase.fish_date import get_time_interval print(get_time_interval(1548575829,1548476921)) {'days': 1, 'hours': 3, 'minutes': 28, 'seconds': 28}

生成随机符合校验规则的身份证和银行卡数据

.. code:: python

from fishbase.fish_random import gen_random_id_card

随机生成一个身份证号

print(gen_random_id_card()) ['3101091986**47'] from fishbase.fish_random import gen_random_bank_card

随机生成一个中国银行的信用卡卡号

print(gen_random_bank_card('中国银行', 'CC')) 625907379**1

创建项目结构

.. code:: python

import os from fishbase.fish_project import init_project_by_yml package_yml = ''' ... project: hellopackage ... tree: ... - README.md ... - requirements.txt ... - setup.py ... '''

通过 yml 文件创建一个项目结构

init_project_by_yml(package_yml, '.') print(os.listdir('./hellopackage')) ['requirements.txt', 'README.md', 'setup.py']

更新记录

2022.9.13 v1.6

2021.7.20 v1.5

2021.6.23 v1.4

2020.4.25 v1.3

2020.3.28 v1.2

2019.12.5 v1.1.16

2019.7.17 v1.1.15

2019.6.25 v1.1.14

2019.6.11 v1.1.13

详细帮助

更多详细文档,请参见:http://fishbase.readthedocs.io/

如有好的建议,欢迎提 issue :https://github.com/chinapnr/fishbase/issues

感谢

自2016年3月初次发布以来,先后发布了20余个版本,非常感谢所有在 fishbase函数包发展过程中做出贡献的朋友们!

fishbase函数包的作者名单,按照时间先后列出如下:

Yi Jun

Leo

Zhang Muqing

Hu Jun

Jia Chunying

Yan Runsha

Miao Tianshi

Jin Xiongwei

Wang Xiaolong